Brijmohan lal Sahu - Facebook
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, December 7, 2014

Program to calculate sum of n number in the series using for loop in C.


program to calculate sum of the series



Code Box
--------------------------------------------------

/*program to calculate sum of the series 
1+2+3+4+.......+n
where n is the limit entered by user
*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum,num;

clrscr();

sum=0;

printf("\nEnter limit : ");
scanf("%d",&num);

printf("\nSeries= ");
for(i=1;i<=num;i++)
{
printf(" + %d ",i);
sum=sum+i;
}
printf("\n\nSum of series= %d",sum);

getch();
}