Q:

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

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).

## 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..."