C Standard Library

C <math.h> - pow() Function



The C <math.h> pow() function returns the base raise to the power of exponent.

Syntax

double pow (double base, double exponent);
float powf (float base, float exponent);
long double powl (long double base, long double exponent);

Parameters

base Specify the base.
exponent Specify the exponent.

Return Value

Returns the base raise to the power of exponent.

Example:

In the example below, pow() function is used to calculate the base raised to the power of exponent.

#include <stdio.h>
#include <math.h>
 
int main (){
  printf("%lf\n", pow(2, 3));
  printf("%lf\n", pow(2.3, 4)); 
  return 0;
}

The output of the above code will be:

8.000000
27.984100

❮ C <math.h> Library