C Program to Find Cube of a Number

C program to calculate or find cuble of a number; In this tutorial, i am going to show you how to find cube of a number in the c program using function, and normal formula.

Algorithm and Programs 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

Follow the below given algorithm to write a program to find cube of a number:

  • 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 result 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 result of the above c program; as follows:

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

More C Programming Tutorials

Leave a Comment