Library Function Math h Pow()

Math h pow() Library Function in C

In the C programming language, the pow function is a mathematical function that calculates the value of a number raised to a certain power Let us understand this with the help of an example of how you can use Library Function Math h Pow() in a C program. The pow function is implemented using the exp and log functions, which calculate the exponential and logarithmic functions, respectively. 

Library Function Math h Pow()

Library Function Math h Pow()

In the C programming language, the pow function is a mathematical function that calculates the value of a number raised to a certain power. It is defined in the math.h header file and has the following prototype:

double pow(double x, double y);
Run
#include<stdio.h>
#include<conio.h> 
int main() {
   double x = 100.0;
   double y = log10(x);
   printf("The common logarithm of %f is %f\n", x, y);
   return 0;
}

Output

The common logarithm of 100.000000 is 2.000000

Some facts about CPow() function

Here are some facts about the pow function in the C programming language:

  1. The pow function is defined in the math.h header file and has the following prototype: double pow(double x, double y).

  2. The pow function takes two arguments, x and y, which represent the base and the exponent, respectively. Both x and y must be double-precision floating-point numbers.

  3. The pow function returns the value of x raised to the power of y as a double-precision floating-point number.

  4. The pow function returns NAN (not a number) if either x or y is NAN, and it returns INFINITE if x is positive and y is positive infinity. It also returns 0 if x is positive and y is negative infinity, and returns INFINITE if x is negative and y is an odd integer.

  5. The pow function can be used to calculate the value of any real number raised to any real power.

  6. The pow function can be used in conjunction with other mathematical functions, such as sin, cos, and sqrt, to perform more complex calculations.

  7. The pow function is implemented using a combination of integer and floating-point arithmetic and is optimized for performance on most modern computers. However, it may not be as accurate as some other methods for calculating powers, such as the exp function.

  8. The pow function is widely used in scientific, engineering, and mathematical applications where the calculation of powers is required.

Arguments of math h Pow() in C

  1. The pow function takes two arguments, x and y, which represent the base and the exponent, respectively.
  2. Both x and y must be double-precision floating-point numbers, and the function returns the value of x raised to the power of y as a double-precision floating-point number.

Note that the pow function returns NAN (not a number) if either x or y is NAN, and it returns INFINITE if x is positive and y is positive infinity. It also returns 0 if x is positive and y is negative infinity, and returns INFINITE if x is negative and y is an odd integer.

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription