Syntax
#include <math.h> double pow(double x, double y);Description
pow calculates the value of x to the power of y.
If y is 0, pow returns the value 1. If x is 0 and y is negative, pow sets errno to EDOM and returns 0. If both x and y are 0, or if x is negative and y is not an integer, pow sets errno to EDOM, and returns 0.
If an overflow results, pow sets errno to ERANGE and returns +HUGE_VAL for a large result or -HUGE_VAL for a small result.
This example calculates the value of 2ⁿ.
#include <stdio.h>
#include <math.h>
int main(void)
{
double x,y,z;
x = 2.0;
y = 3.0;
z = pow(x, y);
printf("%lf to the power of %lf is %lf\n", x, y, z);
return 0;
/****************************************************************************
The output should be:
2.000000 to the power of 3.000000 is 8.000000
****************************************************************************/
}
Related Information