Pages

Tuesday, 16 June 2015

Series 1

Number Series 1:
1+2+3+....+n

Coding:

#include<stdio.h>
int main()
{
int i,n,sum=0;
printf("Please enter the number of terms:");
scanf("%d",&n);
for(i=1;i<=n;i++)
sum=sum+i;
printf("Result is:%d",sum);
return 0;
}

Output:
Please enter the number of terms:5
Result is:15