PROGRAM TO DISPLAY SUM OF SERIES

/*PRORAM TO DISPLAY SUM OF SERIES*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,sum=0,i,j,temp=1;
clrscr();
printf(“Enter the range of series: “);
scanf(“%d”,&n);
if(n<1)
printf(“Range must be greater than zero”);
else
{
printf(“First %d number of series and their sum is: \n”,n);
for(i=1;i<=n;i++)
{
printf(“%d “,temp);
if(i<n)
printf(“+ “);
sum=sum+temp;
temp=temp+2;
}
printf(” = %d”,sum);
}
getch();
}

Leave a Reply

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