C examples for math.h:hypot
function
<cmath> <ctgmath> <math.h>
Returns the hypotenuse of a right-angled triangle whose legs are x and y.
long double hypotl (long double x, long double y); long double hypot (long double x, long double y); double hypot (double x , double y); float hypotf (float x , float y); float hypot (float x , float y); double hypot (Type1 x , Type2 y);
Parameter | Description |
---|---|
x | Floating point values corresponding to the legs of a right-angled triangle. |
y | Floating point values corresponding to the legs of a right-angled triangle. |
The square root of (x^2 + y^2).
#include <stdio.h> #include <math.h> /* hypot */ int main ()/*w w w .j a va 2s.c o m*/ { double leg_x = 3; double leg_y = 4; double result = hypot (leg_x, leg_y); printf ("%f, %f and %f form a right-angled triangle.\n",leg_x,leg_y,result); return 0; }