Answer to Question #15341 in C++ for reymark
write a program that will compute and displays the sum of all numbers divisible by 3 from 1 to 1000.
1
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!
Learn more about our help with Assignments:
C++
Comments
Leave a comment