Library Function hypot in Math Class
Library Function hypot of math.h Header File in C
In this section, we will discuss about library function hypot in math class which is used in C.
The C header file math.h contains the standard math library functions that can be used for performing various mathematical operations. The hypot function is used to find hypotenuse when other two sides are provided.
Library Function hypot of math.h Header File
- In C programming language the hypot function is included in math.h header file.Hypotenuse is the longest side of the right angled triangle.
- The range of input arguments which are passed to hypot function can be of double or float or lonf double type.
Declaration of hypot function
double hypot(double p, double b);
Parameters of hypot function
The hypot function accepts two input arguments which are of double type.
Parameter | Description |
---|---|
p – perpendicular | This value of double function ranges to all positive and negative numbers. |
b – base | This value of double function ranges to all positive and negative numbers. |
Return value of hypot function
The hypot function returns a cube root value and it’s type is double.
Parameter | Return Value |
---|---|
h – hypotenuse | It returns the value in double. |
Implementation of Library Function math.h hypot()
Example 1:
The following code shows the use of hypot function.
#include<stdio.h> #include<math.h> int main() { double p, b; double hypotenuse; p = 5.0; b = 12.0; hypotenuse = hypot(p, b); printf("hypot(%.2lf, %.2lf) = %.2lf", p, b, hypotenuse); return 0; }
Output:
hypot(5.00, 12.00) = 13.00
Example 2:
#include<stdio.h> #include<math.h> int main() { printf("\n The Hypotenuse Value of 10 & 0 = %.4f ", hypot(10, 0)); printf("\n The Hypotenuse Value of 5 & 20 = %.4f ", hypot(5, 20)); return 0; }
Output:
The Hypotenuse Value of 10 & 0 = 10.0000
The Hypotenuse Value of 5 & 20 = 20.6155
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
Login/Signup to comment