# C program to find cube of an integer number using two different methods

In this C program, we are going to find cube of an integer number. Here, we will implement the program by using two methods 1) without using pow() function and 2) using pow() function.
Submitted by Manju Tomar, on September 20, 2017

A cube can be found by calculating the power of 3 of any number. For example, the cube of 2 will be 23 (2 to the power of 3).

Here, we are implementing this program by using two methods:

1. Without using pow() function
2. With using pow() function

## 1) Without using pow() function

In this method, we will just read an integer number and multiply it 3 times.

Consider the program:

```#include <stdio.h>

int  main()
{

int a,cube;

printf("Enter any integer number: ");
scanf("%d",&a);
//calculating cube
cube = (a*a*a);
printf("CUBE is: %d\n",cube);

return 0;
}
```

Output

```Enter any integer number: 8
CUBE is: 512
```

## 2) Using pow() function

pow() is a library function of math.h header file, it is used to calculate power of any number. Here, we will use this function to find the cube of a given number.

Consider the program:

```#include <stdio.h>
#include <math.h>

int  main()
{

int a,cube;

printf("Enter any integer number: ");
scanf("%d",&a);
//calculating cube
cube = pow(a,3);
printf("CUBE is: %d\n",cube);

return 0;
}
```

Output

```Enter any integer number: 8
CUBE is: 512
```

"This is very basic program in C programming language and will be helpful for those who started learning C programming, if you liked, please write comments..."