Write a C++ programme to find out the sum of given n numbers.(using for loop) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a C++ programme to find out the sum of given n numbers.(using for loop)

3rd Sep 2016, 3:38 AM
Raj Bhavsar
Raj Bhavsar - avatar
1 Answer
0
//returns 1+2+...+n int sumTo(int n) { return (n * (n + 1)) / 2; }
3rd Sep 2016, 5:15 AM
Zen
Zen - avatar