C program to find Sum of series S=1+(1+2)+(1+2+3)+..….+(1+2+3+…+n)

By | 05.11.2016

Sum of series S=1+(1+2)+(1+2+3)+..….+(1+2+3+…+n)


Write a C program to find Sum of series S=1+(1+2)+(1+2+3)+..….+(1+2+3+…+n).This program calculates the sum of series upto n i.e user input and produce result.

In this C Program, Firstly we are going to take input integer ‘n’ from the user and then starts loops starting from 1  to n and calculate sum for each iteration.After that just print the result i.e sum  as output on the screen.


Here, the C program to find Sum of series S=1+(1+2)+(1+2+3)+..….+(1+2+3+…+n) is successfully compiled and run on the windows system and produces the output as shown below for different input i.e n. Let’s check out this C Program shown below : :


SOURCE CODE : :


/*  C program to find Sum of series S=1+(1+2)+(1+2+3)+..….+(1+2+3+…+n)  */

#include<stdio.h>

int main()
{
        int n,sum,sum1=0,i,j;

        printf("\nEnter value for n = ");
        scanf("%d",&n);

        for(i=1;i<=n;i++)
    {
                sum=0;
                for(j=1;j<=i;j++)
                {
                    sum=sum+j;
                }
                sum1=sum1+sum;
        }

        printf("\nThe Sum of Series up to Value [ %d ] = [ %d ]\n",n,sum1);

        return 0;
}

OUTPUT : :


/*  C program to find Sum of series S=1+(1+2)+(1+2+3)+..….+(1+2+3+…+n)  */

Enter value for n = 10

The Sum of Series up to Value [ 10 ] = [ 220 ]

Process returned 0

Above is the source code for C program to find Sum of series S=1+(1+2)+(1+2+3)+..….+(1+2+3+…+n) which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.


Thanks for reading the post….

4.3 8 votes
Article Rating
Category: C Programming Number Programs Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
SAKTHI

Can you explain the program

amrita

pls explain the program

Zubaid

/! You can use one loop to do it

using namespace std;
#include
int main()
{

int i,n,s,ts;
s=ts=0;
cin>>n;
for(i=1;i<=n;i++)
{
s=s+i;
ts=ts+s;
}
cout<<ts;
}