Ask your own question, for FREE!
Computer Science 10 Online
OpenStudy (noorik.):

The question is: 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. Find the sum of all the multiples of 3 or 5 below 1000. My code is: int x = 1; int y = 0; while (x > 1000) { if (x%3==0){ y = y+x; } ++x; } cout << y; but it doesn't work.

OpenStudy (anonymous):

#include <iostream> using namespace std; int main() { int x=1,sum=0; while(x<10) { if(x%3==0||x%5==0)//Multiples of 3 and 5 { sum=sum+x;//sum of the multiples } x++; } cout<<sum;//Displaying the Result return 0; } Hope this may helpful to you... If any doubts please ask here....

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!