65 789
Assignments Done
99,4%
Successfully Done
In October 2018

Answer to Question #13883 in C++ for najh

Question #13883
c++ program (using while loop)that input a number and output the sum from 1 up to the input value ?
Expert's answer
#include<iostream>
int main()
{
int n;
std::cout <<
"Enter n: ";
std::cin >> n;

int s=0;
for (int i=1; i<=n;
i++)
{
s+=i;
};
std::cout << "Sum of numbers from 1 to "
<< n << " is " << s << std::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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions