Answer to Question #157801 in C++ for Melen

Question #157801

Add numbers from 1 to 100 and display the sum


1
Expert's answer
2021-01-23T10:20:09-0500

//correct answer

#include <iostream>

using namespace std;

int main()

{

int sum = 0;

for(int i = 1; i<= 100; i++)

{

sum += i;

}

cout << "Sum from 1 to 100: " << sum << endl;

return 0;

}


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