Calculate sum of all numbers upto n


#include<stdio.h>
#include<conio.h>
int main()
{
int n,i,sum=0;
clrscr();
printf("enter the end term of series");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+i;
}
printf("\n the sum of the series is %d",sum);
getch();
return 0;
}

0 comments:

Post a Comment