Cube of an integer using pow() function

C program to find cube of a number using pow() function.

Program

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
	double num, cube;

   	printf("Enter any integer number: ");
   	scanf("%lf",&num);

   	cube = pow(num,3);
   	printf("\nCube of %lf is: %lf",num,cube);

	getch();
}

Output

Enter any integer number: 5

Cube of 5.000000 is: 125.000000

Explanation

In C, pow() function is used to find the power of any number. It is a library function of math.h header file.
Syntax for pow() function in C is as follows,
double pow (double base, double exponent);

In the above program, this function is used to find the cube of a number.
For this, base value is the number entered by the user, i.e., value in variable 'num' and exponent value is set to 3.
If it would have been square, then the value of exponent would be set to 2.

Note that %lf is the format specifier for double data type.