Site icon Codeforcoding

pow function in C programming Language

pow function in C programming Language

In this tutorial, we will discuss pow function in C programming Language

Description

Pow()  in C is used to find the power of the given number

The pow() function in C programming language (C library function) returns x raised to the power of y

pow(): In the C Programming Language, The pow() Arithmetic function calculate x raised to the power of y

 

Declaration

The declaration for the pow()  in the C Programming language is

double pow(double x,double y );

Parameter or Argument

parameter of pow() function is:

x,y are the arguments of this function

 

Return

The pow() function returns x raised to the power of y

Required header

In this Language, The required header for the pow function is

#include <math.h>

Example

The following example shows the usage of pow()

pow function in C

program 1
#include <stdio.h>
#include <math.h>
int main()
{

    printf("The Power value of pow(2,3) is %f\n",pow(2,3));
    printf("The Power value of pow(3,4) is %f\n",pow(3,4));
    getch();
    return 0;
}

 

When the above program is compiled, it will produce the following result

The power value of pow(2,3) is 8.000000

The power value of pow(3,4) is 81.000000

 

Example 2

#include <stdio.h>
#include <math.h>
int main()
{
    //define temporary variable
    double val1,val2;
    double result;
    printf("Enter the number one :");
    //get first input from user
    scanf("%lf",&val1);
    printf("Enter the number two :");
    //get second input from user
    scanf("%lf",&val2);
    //calculate power
    result=pow(val1,val2);
    //Display power value
    printf("power value is: %lf\n",result);
getch();
    return 0;
}

When above program is compiled, it will produce the following result

Enter te number one :5
Enter te number two :6
Power value is :15625.000000

 

Suggested for you

trunc() function in C langue

exp() function in C language

sqrt() function in C language       

cosh function   in C  language                               

sinh function in C language

tanh function in C language

abs function in C language

floor function in C language

ceil function in C language

round function in C language

 

suggested for you

Function in C language

User defined function in C language

Arithmetic functions in C Language

String function in C language

 

 

trunc function in C programming language
sqrt function in C programming language
Exit mobile version