C Program to Find Sum of series 1³+2³+3³+….+n³

C Program to Find Sum of series 1³+2³+3³+….+n³

To find sum of series 1³+2³+3³+….+n³ in c; Through this tutorial, we will learn how to find sum of series 1³+2³+3³+….+n³ in c using a formula, for loop, function, and recursion.

Programs to Find Sum of series 1³+2³+3³+….+n³ in C

  • C Program to Find Sum of series 1³+2³+3³+….+n³ using Standard Formula
  • C Program to Find Sum of series 1³+2³+3³+….+n³ using For Loop
  • C Program to Find Sum of series 1³+2³+3³+….+n³ using Function
  • C Program to Find Sum of series 1³+2³+3³+….+n³ using Recursion

C Program to Find Sum of series 1³+2³+3³+….+n³ using Standard Formula

/* Sum of Cubes of n Natural Numbers */

#include <stdio.h>
#include <math.h>

int main()
{
  int Number, Sum = 0;

  printf("\n Please Enter any positive integer \n");
  scanf(" %d",&Number);

  Sum = pow(((Number * (Number + 1))/ 2), 2);
 
  printf("\n The Sum of Series for %d = %d ",Number, Sum);
}

The output of the above c program; is as follows:

Please Enter any positive integer 
10
The Sum of Series for 10 = 3025 

C Program to Find Sum of series 1³+2³+3³+….+n³ using For Loop

/* Sum of Cubes of n Natural Numbers */

#include <stdio.h>
#include <math.h>

int main()
{
  int Number, i, Sum = 0;

  printf("\nPlease Enter any positive integer \n");
  scanf("%d",&Number);

  Sum = pow(((Number * (Number + 1))/ 2), 2);
  
  for(i =1; i<=Number;i++)
  {
    if (i != Number)
       printf("%d^3 + ",i);
    
    else
       printf("%d^3 = %d ",i, Sum);
  }
}

The output of the above c program; is as follows:

Please Enter any positive integer 
5
1^3 + 2^3 + 3^3 + 4^3 + 5^3 = 225 

C Program to Find Sum of series 1³+2³+3³+….+n³ using Function

/* Sum of Cubes of n Natural Numbers */

#include <stdio.h>
#include <math.h>

void Sum_Of_Series(int);

int main()
{
  int Number;

  printf("\n Please Enter any positive integer \n");
  scanf("%d",&Number);

  Sum_Of_Series(Number);
}

void Sum_Of_Series(int Number)
{
  int i, Sum = 0;
  Sum = pow (((Number * (Number + 1))/ 2), 2);;
  
  for(i =1;i<=Number;i++)
  {
   if (i != Number)
     printf("%d^3  + ",i);

   else
     printf(" %d^3 = %d ", i, Sum); 
  } 
}

The output of the above c program; is as follows:

Please Enter any positive integer 
5
1^3  + 2^3  + 3^3  + 4^3  +  5^3 = 225 

C Program to Find Sum of series 1³+2³+3³+….+n³ using Recursion

/* Sum of Cubes of n Natural Numbers */

#include <stdio.h> 

int Sum_Of_Series(int);

int main()
{
  int Number, Sum;

  printf("\nPlease Enter any positive integer \n");
  scanf("%d",&Number);

  Sum =Sum_Of_Series(Number);

  printf("\nSum of the Series  = %d",Sum);
}

int Sum_Of_Series(int Number)
{
  if(Number == 0)
    return 0;
  
  else      
    //Recursive Calling   
    return (Number * Number * Number) + Sum_Of_Series(Number-1);  
}

The output of the above c program; is as follows:

Please Enter any positive integer 
10
Sum of the Series  = 3025

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *