Pow() function in C

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 header file. pow() function in C language is use to find out the power of a number i.e; it is use to calculate ” xy ” in C programming.

How does pow() function works ?

As discussed above pow() function in C is use 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 works with all types of data types except char, string and Boolean. 

C Code for using pow()

Lets take an example and understand how to use pow() function in C code. There are many other library functions and header files in C programming language which can be use according to the need, you can visit our library functions in C page for detailed information on library function.
Run
#include <stdio.h> // header files
#include <math.h> // library files

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

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