Q:

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

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Number Solved Programs – C Programming

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program to find Cosine Series using function cos... >>
<< C Program to find sum of series : 1 + 3^2/3^3 + 5^...