118. C Program to Compute the 1+8+27+64+ …………+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 1+8+27+64+ …………………+n upto nth term.
- where 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+8+27+64+ …………………………….+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*i;
}
printf("sum of series cubes upto %d numbers is %d",n,sum);
return 0;
}