^{y}) using recursion in C programming.

**Example:**

Input any number: 5

Input power: 2

Output: 25

Also try this program using other programming techniques - C program to find power using pow() function.

C program to find power of any number using loops.

### Required knowledge

Basic C programming, Functions, Recursion### Program

/** * C program to find power of any number using recursion */ #include <stdio.h> /* Power function declaration */ double pow(double num, int power); int main() { int x, y; double power; /* * Reads two integer from user */ printf("Enter any number: "); scanf("%d", &x); printf("Enter power of the number: "); scanf("%d", &y); power = pow(x, y); //Calls pow function printf("%d raised to %d = %.2f\n", x, y, power); return 0; } /** * Finds power of any number (Computes x raised to power y). * @param num Integer whose power is to be calculated * @param power Raised to num * @return num raised to power. */ double pow(double num, int power) { if(power == 0) return 1; return num * pow(num, power-1); }

Output

Enter any number: 10

Enter power of the number: 3

10 raised to 3 = 1000.00

Enter power of the number: 3

10 raised to 3 = 1000.00

Happy coding ;)

- Function and recursion programming exercises index.
- C program to find cube of any number using function.
- C program to print all natural numbers using recursion.
- C program to find all even or odd numbers using recursion.
- C program to find sum of all natural numbers 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(HCF) of any two numbers using recursion.
- C program to check even or odd numbers using recursion.
- C program to check whether the given number is prime, armstrong or perfect number.