# Basic C Exercises

**C program to find power of a number using pow function**

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.

**Required knowledge**

Data Types in c,
Input/Output in C,
Operators,
Variables 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 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.

**Output:**

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