pow function in C programming Language
- Home
- function in C
- pow function in C programming Language
- On
- By
- 0 Comment
- Categories: function in C, pre-define maths function in C
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
suggested for you
User defined function in C language
Arithmetic functions in C Language