English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The pow(x,y) function calculates the y-th power of the parameter x.
The pow() function takes two parameters (base value and power value) and then returns the power raised to the base. For example
The pow() function is defined in the math.h header file.
double pow(double x, double y)
x -- Represents the floating-point value of the base. y -- Represents the floating-point value of the exponent.
To find the power of an int or float variable, you can use the explicit type conversion operator to convert the type to double explicitly.
int base = 3; int power = 5; pow(double(base), double(power));
#include <stdio.h> #include <math.h> int main() { double base, power, result; printf("Enter base: "); scanf("%lf",&base); printf("Enter exponent: "); scanf("%lf",&power); result = pow(base, power); printf("%.1lf^%.1lf = %.2lf, base, power, result); return 0; }
Output Result
Enter base: 2.5 Enter exponent: 3.4 2.5^3.4 = 22.54