Introduction :
In C programming, calculating mathematical operation is very important to create simple and complex applications. Calculating exponentiation is also an important task. You can calculate exponentiation using pow() function in C programming language. In this article, I shall show you how to use pow() function in C programming language. Here, I also show you the syntax and usage of pow() function.
What is the pow() function :
The pow() function is a function of math.h library or header file. It is used to calculate the power of a number means raise a base number to a specified exponent power. This function is generally used in graphics, finance, scientific applications etc.
Syntax of the pow() function :
In C programming language, the following code is the syntax of the pow() function.
double pow(double x, double y);
The pow() function takes two double type parameters. The first parameter (x) is the base number that you want to raise to a power. The second parameter (y) is the exponent to which the base number is raised. It returns the result of raising the base to the power of exponent. The return type will be double.
About the program :
This is a simple example of how to use pow() function in C programming language. Here, the program asks you to enter two numbers (base and exponent). Then, it calculates the result using pow() function and display the result on the console screen.
Explanation of the program :
First, include the necessary header files such as math.h and stdio.h in the program. Then, declare three double type variables such as “x”, “y” and “result” in the main() function. Now, ask the user to enter the base and exponent number using printf() function. You have to use scanf() function to take the input from user and store in “x” and “y” variables.
After that, calculate the exponentiation using pow() function and store in “result” variable. Finally, display the result of the exponentiation using printf() function. Here, I use “%.2lf” to display the result upto 2 decimal places.
How run the program :
At first, install VS Code on your PC. Then, open VS Code and create new file like “pow.c”. Now, copy the following code and paste in the “pow.c” file. After that, save the file and run the program on your PC.
Source code of the program :
The following code is the source code of the program.
/*Developed by Puskar Jasu*/
#include <math.h>
#include <stdio.h>
int main(void)
{
double x, y, result;
printf("Enter the base number\n");
scanf("%lf", &x);
printf("Enter the exponent number\n");
scanf("%lf", &y);
result = pow(x, y);
printf("If base %.2lf and exponent %.2lf, result will be %.2lf\n", x, y, result);
return 0;
}
Output of the program :
You can see the output of the program like below image.

Conclusion :
Finally, you have learned how to use pow() function in the C programming language. Now you can use pow() function in your program. Thank you for visiting my site.