Write a C program to input any number from user and find cube of the given number using function. How to find cube of a given number using function in C programming. C function to find cube of any number.

Input any number: 5

Output: 125

Till now we already know how to find power of any number (a^b) using pow() function and also finding power of any numbers using loop. Here we will be writing our custom function to find cube of any number using functions.

Happy coding ;)

**Example:**Input any number: 5

Output: 125

### Required knowledge

Basic C programming, FunctionsTill now we already know how to find power of any number (a^b) using pow() function and also finding power of any numbers using loop. Here we will be writing our custom function to find cube of any number using functions.

### Program to find cube using function

/** * C program to find cube of any number using function */ #include <stdio.h> /** * Function to find cube of any number * @num Number whose cube is to be calculated */ double cube(double num) { return (num * num * num); } int main() { int num; double c; printf("Enter any number: "); scanf("%d", &num); c = cube(num); printf("Cube of %d is %.2f\n", num, c); return 0; }

Output

Enter any number: 5

Cube of 5 is 125.00

6, 28, 496, 8128,

Cube of 5 is 125.00

6, 28, 496, 8128,

Happy coding ;)

### You may also like

- Function programming exercises index.
- C program to find power of any number using recursion.
- C program to find maximum and minimum between two numbers using functions.
- C program to find diameter circumference and area of circle using functions.
- C program to check even or odd using functions.
- C program to check prime, strong, armstrong or perfect numbers using functions.
- C program to print all natural numbers between 1 to n using recursion.
- C program to find sum of all even or odd numbers between 1 to n using recursion.
- C program to find reverse of any number using recursion.
- C program to find factorial of any number using recursion.
- C program to find GCD of any number using recursion.
- C program to find LCM of any number using recursion.

< pre>< code >----Your Source Code---- < / code > < / pre > (Remove spaces from pre and code tags)