How to use the pow function in the C language?
In the C language, the pow function is used to calculate the power of a specified number. Its prototype is as follows:
double pow(double x, double y);
In this function, x is the base and y is the exponent. The function returns the result of x raised to the power of y.
Here is an example using the pow function:
#include <stdio.h>
#include <math.h>
int main() {
double result = pow(2, 3);
printf("2的3次幂为: %f\n", result);
return 0;
}
The output result is:
2的3次幂为: 8.000000
Please note that the return value of the pow function is of type double, so you need to use the %f format specifier to print the result.