calculate the length of the hypotenuse of a right-angled triangle
#include <math.h> double hypot( double x, double y );
The hypot() function computes the length of the hypotenuse of a right triangle whose sides are x and y adjacent to that right angle. The calculation is equivalent to:
sqrt( x*x + y*y )
The computation may cause an overflow, in which case the matherr() function will be invoked.
The value of the hypotenuse.
#include <stdio.h>
#include <math.h>
void main()
{
printf( "%f\n", hypot( 3.0, 4.0 ) );
}
produces the output:
5.000000
WATCOM
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |