English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

pow() function in C

The functionpow()used to calculate the power raised to the base value. It has two parameters. It returns the power raised to the base value. Declared in the 'math.h' header file.

This ispow()C language syntax,

double pow(double val1, double val2);

Here,

val1-to calculate itspoweris the base value.

val2-the power value.

This ispow()C language example,

Example

#include<stdio.h>
#include<math.h>
int main() {
   double x = 5.5;
   double y = 4.0;
   double p;
   p = pow(x, y);
   printf("The value : %lf", p);
   return 0;
}

Output result

The value : 915.062500

The following error may occur on some online compilers.

undefined reference to `pow'
error: ld returned 1 exit status

The above error occurs because we added the 'math.h' header file but have not linked this program to the following mathematical library.

libm.a

Link the program with the library above so thatpow()Resolving the call to the function.