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

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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