Syntax
#include <math.h> double hypot(double side1, double side2);Description
hypot calculates the length of the hypotenuse of a right-angled triangle based on the lengths of two sides side1 and side2. A call to hypot is equivalent to:
sqrt(side1 * side1 + side2 * side2);Returns
hypot returns the length of the hypotenuse. If an overflow results, hypot sets errno to ERANGE and returns the value HUGE_VAL. If an underflow results, hypot sets errno to ERANGE and returns zero.
This example calculates the hypotenuse of a right-angled triangle with sides of 3.0 and 4.0.
#include <math.h>
int main(void)
{
double x,y,z;
x = 3.0;
y = 4.0;
z = hypot(x, y);
printf("The hypotenuse of the triangle with sides %lf and %lf"
" is %lf\n", x, y, z);
return 0;
/****************************************************************************
The output should be:
The hypotenuse of the triangle with sides 3.000000 and 4.000000 is 5.000000
****************************************************************************/
}
Related Information