rabbinur

series

Aug 16th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3.  void main()
  4.  {
  5.   int n, i, sum=0, j;
  6.   clrscr();
  7.   cout<<"1+2+4+7+11+16+--------+n"<<endl;
  8.   cin>>n;
  9.   j=1;
  10.   for(i=0; i<=n; i=i+j)
  11.   {
  12.   sum=sum+i;
  13.   j++;
  14.   }
  15.   cout<<"Total of the series="<<sum<<endl;
  16.   getch();
  17.  }
Advertisement
Add Comment
Please, Sign In to add comment