Ad

Write a program in c++ to find the sum of following series : 
s = 1 + 2 + 3 + 4 + .......... + n




#include<iostream.h>
#include<conio.h>
using namespace std;
void main (){
int s= 0 ,i, n ;
cout<<"Enter Last Number : ";
cin>>n;
for(i=1; i<=n; i++)
s=s+i;
cout<<"\n Summation of first "<<n;
cout<<" +ve Interger Number is "<<s;
}

 Output--

Enter Last Number : 4 

 Summation of first 4 +ve Interger Number is 10 

 [Program finished]

Post a Comment

Previous Post Next Post