117. C Program to Compute the 1+4+9+16+ ………………………………+n Series.
How does this program work?
- This program is used to compute the sum of series for the given order.
- Here we are going to find the series for Square of numbers upto nth term.
- The nth term is the user input.
- Computing the given series is easy by Using the simple for loop condition.
Here is the code
//1+4+9+16+25+ ……………………………+n
#include <stdio.h>
int main(void)
{
int n,sum = 0;
printf( "Enter series of number\n");
scanf("%d",&n);
for(int i=1; i<= n; i++)
{
sum+=i*i;
}
printf("sum of series Squares upto %d numbers is %d",n,sum);
return 0;
}