PROGRAM TO DISPLAY A SERIES AND FIND ITS SUM

/*PROGRAM TO DISPLAY A SERIES AND FIND ITS SUM*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,sum=0;
clrscr();
printf(“Enter the limit of series: “);
scanf(“%d”,&n);
printf(“Series and its sum is: \n”);
for(i=1;i<=n;i++)
{
if(i>1)
printf(“(“);
for(j=1;j<=i;j++)
{
printf(“%d”,j);
sum=sum+j;
if((j==i)&&j==1)
printf(“+”);
if(j<i)
printf(“+”);

}
if(i>1)
printf(“)”);
if((i>1) &&(i<n))
printf(“+”);
}
printf(” = %d”,sum);
getch();
}

Leave a Reply

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