# hypot Function

Calculates the square root of the sum of squared double precision floating-point values.

Include

<math.h>

Prototype

double hypot(double x, double y);

Arguments

 x first argument, or length of one side y second argument, or length of other side

Return Value

Returns the square root of a sum of the arguments squared, being the hypotenuse of a right-angled triangle with perpendicular sides of length x and y.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#include <math.h>
#include <stdio.h>

int main(void)
{
double x, y, h;

x = 1.75;
y = 2.05
h = hypot(x, y);
printf("The hypotenuse of a right-angle triangle with other side lengths of %f and %f is %f\n", x, y, h);
}

Example Output

The hypotenuse of a right-angle triangle with other side lengths of 1.750000 and 2.050000 is 2.695366