66 926
Assignments Done
99,1%
Successfully Done
In October 2018

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.
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions