pow() in c – pow C Library Function

pow() in c: The function double pow(double base, double exponent); returns base raised to the power of exponent (baseexponent).

Function prototype of pow

double pow(double base, double exponent);
  • base : A floating point value of base.
  • exponent : A floating point value of exponent.

Return value of pow

pow.c: It returns base raised to the power of exponent. If the result of pow function is too large or too small to be represented by a return type value, it causes a range error.

C program using pow function

The following program shows the use of pow function to calculate xy.

pow C Library Function

#include <stdio.h>
#include <math.h>
 
int main ()
{
  double base, exponent, result;
  printf("Enter base and exponent\n");
  scanf("%lf %lf", &base, &exponent);
   
  result = pow(base, exponent);
  printf("%lf^%lf = %lf\n", base, exponent, result);
   
  return 0;
}

Output

Enter base and exponent
2 5
2.000000^5.000000 = 32.000000
Enter base and exponent
5 0
5.000000^0.000000 = 1.000000