C pow() function
C pow() function - Compute power
Syntax:
double pow(double x, double y)
The pow() function is used to calculate the value of x to the power of y.
Parameters:
Name | Description | Required /Optional |
---|---|---|
x | Floating point base value. | Required |
y | Floating point power value. | Required |
Return value from pow()
- Returns the value 1 if y is 0.
- Returns 0 if x is 0 and y is negative.
- Returns 0 if both x and y are 0, or if x is negative and y is not an integer.
Example: pow() function
The following example shows the usage of pow() function.
#include <math.h>
#include <stdio.h>
int main(void)
{
double x, y, z;
x = 2.0;
y = 4.0;
z = pow(x,y);
printf("%lf to the power of %lf is %lf\n", x, y, z);
x = 2.2;
y = 3.2;
z = pow(x,y);
printf("\n%lf to the power of %lf is %lf\n", x, y, z);
}
Output:
2.000000 to the power of 4.000000 is 16.000000 2.200000 to the power of 3.200000 is 12.466731
C Programming Code Editor:
Previous C Programming: C modf()
Next C Programming: C sqrt()
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/c-programming/math/c-pow.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics