C++ program to find sum of series 1 + 2 + 3 +……+ n

C++ program to find sum of series 1 + 2 + 3 +......+ n

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int i,n,sum=0;
cout<<“1+2+3+……+n”;
cout<<“nEnter the value of n:”;
cin>>n;

for(i=1;i<=n;++i)
sum+=i;
cout<<“nSum=”<<sum;
getch();
}

8 thoughts on “C++ program to find sum of series 1 + 2 + 3 +……+ n

  1. muskaan dhasmana

    program in c++ to find sum of series sum=1+(1+2)+(1+2+3)+……………..n

    Reply
    1. SULTAN SHERYAR

      #include
      #include

      void main()
      {
      int i,j,n,sum=0;
      clrscr();
      n=10;
      for(i=1;i<=n;i++)
      {
      for(j=1;j<=i;j++)
      {
      sum+=j;
      }
      }
      cout<<"Sum: "<<sum;
      getch();
      }

      Reply
  2. Gohar

    bhai may nay ek program solve karna hy jis may hum nay ye series banana 1+1/4+1/8+1/12+…1/100
    kay ap bata saktay ho kaisay maloom karni hy c++ may

    Reply
    1. Mujeeb Ijaz

      #include
      using namespace std;

      void main()
      {
      float num=0;
      for (float i=4; i<=100; i=i+4)
      {
      num=num+(1/i);
      }
      num=num+1;
      cout << num;

      system("pause");
      }

      Reply
  3. tanvir

    bro what is the program for this series

    1+1+2+1+2+3+1+2+3+4+…………..1+2+3+………+n

    Reply
    1. Ravi Mishra

      #include
      #include
      void main()
      {
      int i,j,n,sum=0;
      clrscr();
      cout<>n;
      for(i=1;i<=n;i++)
      {
      for(j=1;j<=i;j++)
      {
      sum+=j;
      if(j==n)
      {
      cout<<j;
      }
      else
      {
      cout<<j<<"+";
      }
      }
      }
      cout<<"\nTotal Sum="<<sum;
      getch();
      }

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *