Answer to Question #15341 in C++ for reymark

Question #15341
write a program that will compute and displays the sum of all numbers divisible by 3 from 1 to 1000.
1
Expert's answer
2012-09-27T11:01:41-0400
#include <iostream>




using namespace std;




void main(){

int sum = 0;

for(int i = 1; i < 1000; i++){

if(i % 3 == 0)

sum += i;

}

cout << "sum: " << sum << endl;

}

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
APPROVED BY CLIENTS