Write a C program to input any two numbers x and y from user and find power of both number i.e. x^y using inbuilt library pow() function. How to find power of two numbers in C programming. How to use pow() function in C programming. C program to compute power of two numbers.

Also view this program without using other programming methods - C program to find power of any number using loop.

C program to find power of two numbers using recursion.

Input number1: 5

Input number2: 2

Output x^y = 25

Happy coding ;)

Also view this program without using other programming methods - C program to find power of any number using loop.

C program to find power of two numbers using recursion.

**Example:**Input number1: 5

Input number2: 2

Output x^y = 25

### Required knowledge

Fundamentals of C, Data types, Talking user input in C### 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 x, y, power; // Reads two numbers from user to calculate power printf("Enter any two number x and y : "); scanf("%lf%lf", &x, &y); // Calculates x^y power = pow(x, y); printf("x^y = %.0lf", power); return 0; }

Output

Enter any two number x and y : 5

3

x^y = 125

3

x^y = 125

**Note:**%.0lf is used to print fractional values up to 0 decimal places. You can also use %lf to print fractional values normally up to six decimal places.

Happy coding ;)

### You may also like

- Basic programming exercises index.
- C program to perform addition, subtraction, multiplication, division and modulus operation.
- C program to find diameter, circumference and area of circle.
- C program to convert length from centimeter to meter and kilometer.
- C program to convert temperature from Celsius to Fahrenheit.
- C program to convert days to years, weeks and days.
- C program to find third angle of triangle if two angles are given.
- C program to calculate area of equilateral triangle.
- C program to calculate total, average and percentage.
- C program to calculate Simple Interest.
- C program to check leap year.
- C program to enter week number and print day of week name.
- C program to enter month number and print total number of days in month.
- C program to find cube of any number using functions.

< code >< pre > -- Your source code -- < /pre >< /code > (Remove spaces from pre and code tags).