#include <stdio.h>
#include <stdlib.h>
void main()
{
int i, n, sum=0,term=1;
printf ("Enter number of terms ") ;
scanf ("%d" ,&n) ;
for(i=1;i<=n;i++)
{
sum+=term;
term=term+i;
}
printf ("The sum of series upto %d terms is %d\n", n, sum) ;
}
#include <stdlib.h>
void main()
{
int i, n, sum=0,term=1;
printf ("Enter number of terms ") ;
scanf ("%d" ,&n) ;
for(i=1;i<=n;i++)
{
sum+=term;
term=term+i;
}
printf ("The sum of series upto %d terms is %d\n", n, sum) ;
}
No comments:
Post a Comment