Cube of an integer
C program to find cube of an integer number without using pow() function.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int num, cube;
printf("Enter any integer number: ");
scanf("%d",&num);
cube = (num * num * num);
printf("\nCube of %d is: %d",num,cube);
getch();
}
Output
Enter any integer number: 5
Cube of 5 is: 125
Explanation
In the above program, cube of a number is calculated by multiplying the number three times to itself.
Cube of a number can also be calculated using the pow() function, which is explained in next program.
cube = (num * num * num);
Cube of a number can also be calculated using the pow() function, which is explained in next program.