C++ program to find sum of series 1 + 2 + 3 +……+ n
Here you will get source code of C++ program to find sum of series 1 + 2 + 3 +……+ n terms.
For Example
1 + 2 + 3 + 4 + 5 + ……+ n
Flowchart to find sum of series 1+2+3+4+….+n
Example of C++ program to find sum of series 1 + 2 + 3 +……+ n
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <iostream> using namespace std; int main() { int n,i=1,sum=0; cout<<"\nEnter the value of n : "; cin >> n; while(i<=n) { sum=sum+i; i++; } cout<<"\n Sum of series upto "<<n<<" is "<<sum; return 0; } |
Output
Enter the value of n : 5
Sum of series upto 5 is 15
Other Similar Programs
C++ program to find sum of series 1+1/2+1/3…+1/100
C++ Program to print given series:1 2 4 8 16 32 64 128…. n
Check out our other C++ programming Examples