Write a C program to input two numbers from user and find their power using `pow()`

function. How to find power of a number in C programming. How to use `pow()`

function in C programming.

**Example**

**Input**

Enter base: 5 Enter exponent: 2

**Output**

5 ^ 2 = 25

## Required knowledge

Arithmetic operators, Data types, Basic input/output

## Program to find power of a number

```
/**
* C program to find power of any number
*/
#include <stdio.h>
#include <math.h> // Used for pow() function
int main()
{
double base, expo, power;
/* Input two numbers from user */
printf("Enter base: ");
scanf("%lf", &base);
printf("Enter exponent: ");
scanf("%lf", &expo);
/* Calculates base^expo */
power = pow(base, expo);
printf("%.2lf ^ %.2lf = %.2lf", base, expo, power);
return 0;
}
```

`%.2lf`

is used to print fractional value up to 2 decimal places.

Also check other approaches to find power of a number.

Read more -

Output

Enter base: 5 Enter exponent: 3 5 ^ 3 = 125

Happy coding ðŸ˜‰

### Recommended posts

- Basic programming exercises index.
- C program to find square root of any number.
- C program to convert temperature from Celsius to Fahrenheit.
- C program to convert days to years, weeks and days.
- C program to calculate total, average and percentage.
- C program to calculate Simple Interest.
- C program to enter month number and print total number of days in month.

doubt, write here. I willhelp my best.<pre><code> ----Your Source Code---- </code></pre>