## Algorithm

Power of a Number is one of the basic mathematical calculation.

Logic here to calculate the power of a number -

1. xn = x * x(n times)
2. 2 ^ 3 = 2 * 2 * 2 = 8
3. 4 ^ 3 = 4 * 4 * 4 = 64

There is also other solution in C programming for this power. There is a function called `pow()` in C Programming.

## Code Examples

### #1 Power of a Number in C using For Loop

```Code - C Programming```

``````#include <stdio.h>
int main(void){

scanf("%d", &number);

scanf("%d", &power);

for(i = 1; i  <  power; i++){
}
}
``````
Copy The Code &

Input

cmd
5 3

Output

cmd

### #2 Power of a number using pow() function on math library in C

```Code - C Programming```

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

int main(void){

scanf("%d", &number);

scanf("%d", &power);

}
``````
Copy The Code &

Input

cmd
5 3

Output

cmd

### #3 Power of a Number in C using Recursion

```Code - C Programming```

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

int calculatePower(int number, int power) {
if (power != 0){
return (number * calculatePower(number, power - 1));
}
else{
return 1;
}
}

int main(void){

scanf("%d", &number);

scanf("%d", &power);

}``````
Copy The Code &

Input

cmd
5 3

Output

cmd
2. `pow()` function of math.h header library