C Program to Find Cube of a Number

C Program to Find Cube of a Number

C program to calculate or find cuble of a number; Through this tutorial, you will learn how to find cube of a number in the c program with the help of function, and normal formula.

Programs to Find Cube of a Number in C

Follow the following algorithm and program to find cube of a number in c:

  • Algorithm to Find Cube of a Number
  • C Program to Find Cube of a Number using Formula
  • C Program to Find Cube of a Number using Function

Algorithm to Find Cube of a Number

Use the following algorithm to write a program to find cube of a number; as follows:

  • Step 1: Start Program
  • Step 2: Read the number from user and store it in a.
  • Step 3: Calculate cube of number using a * a * a
  • Step 4: Print cube of number
  • Step 5: Stop Program

C Program to Find Cube of a Number using Formula

/* C Program to find Cube of a Number */
 
#include<stdio.h>
 
int main()
{
  int number, cube;
 
  printf(" \n Please Enter any integer Value : ");
  scanf("%d", &number);
  
  cube = number * number * number;
  
  printf("\n Cube of a given number %d is  =  %d", number, cube);
 
  return 0;
}

The output of the above c program; as follows:

Please Enter any integer Value : 10
Cube of a given number 10 is  =  1000

C Program to Find Cube of a Number using Function

/* C Program to find Cube of a Number using Function */
 
#include<stdio.h>

int FindCube(int Number);
 
int main()
{
  int number, cube;
 
  printf(" \n Please Enter any integer Value : ");
  scanf("%d", &number);
  
  cube = FindCube(number);
  
  printf("\n Cube of a given number %d is  =  %d", number, cube);
 
  return 0;
}

int FindCube(int Number)
{
	return Number * Number * Number;
}

The output of the above c program; as follows:

Please Enter any integer Value : 5
Cube of a given number 5 is  =  125

Recommended C Programs

AuthorAdmin

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 *