I just want to make sure this program does exactly as it was intended to do. I'm trying to find all the multiples of 3 and 5 from 1000 and add those numbers to an accumulator and print the result.
Is this how you find the multiples of 3 and 5 from 1000?
#include <iostream>
usingnamespace std;
int main ()
{
int total = 0;
for (int n = 3; n <= 1000; n++)
{
if (n % 3 == 0)
total += n;
elseif (n % 5 == 0)
total += n;
else
total += 0;
}
cout << total;
}