Write a c program to find the sum of series 1^3 + 2^3 + 3^3 …. + n^3

Here is the code of the program to calculate the sum of the cube of the numbers up to nth terms 


#include<stdio.h>

#include<math.h>


int main()
{



int n,j;

int sum=0;

printf("Enter the value of n ");

scanf("%d",&n);

sum = pow(((n * (n + 1) ) / 2),2);


 printf("Sum of the series : ");


 for(j=1;j<=n;j++)
{

 if (j!= n)

 printf("%d^3 + ",j);

 else

 printf("%d^3 = %d ",i,sum);

 }


return 0;
}

Comments