Answer to Question #24157 in C++ for OMAR ALMUTAIRI

Question #24157
Q2: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Write an algorithm to Find the sum of all the multiples of 3 or 5 below 1000.
1
Expert's answer
2013-02-12T10:29:30-0500
#include <conio.h>
#include <iostream>

using namespace std;

void main()
{
long sum = 0;
for (int number = 3; number < 1000; number++)
if ((number % 3 == 0) || (number % 5 == 0))
sum += number;
cout << "The sum of the multiples of 3 or 5 below 1000 is: " << sum << endl;
_getch();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS