Skip to main content

Pow() function in C

 


What is Pow() function in C?

C Programming Language has many pre-defined library functions stored in various different header files. pow() function is one such pre-defined library function stored in the header file. pow() function in C language is used to find out the power of a number i.e; it is used to calculate ” XY ” in C programming

 

 

How does the pow() function work?

As discussed above pow() function in C is used to determine the power of an exponent. We can use pow() in our code after including the header file. pow() function in C is denoted as pow(x,y) hence, it accepts two values. x is the exponent value and y is the power value


Syntax of pow() function in C

  • pow(exponent, power)

Both exponent and power can be any real number, pow() function work with all types of data types except char, string, and Boolean. Let's take an example and understand how to use the pow() function in C code. There are many other library functions and header files in C programming language which can be used according to the need, you can visit our library function in C page for detailed information on library function


C Code for using pow()

#include 
#include 
int main()
{
    double a = 2.5, ans=0.0;
    int b = 2;
    ans= pow(a,b);
 
    printf("The result of %f to the power %d is %f",a,b,ans);
 
    return 0;
}
Output
The result of 2.500000 to the power 2 is 6.250000

 

Comments