C Standard Library

C <math.h> - hypot() Function



The C <math.h> hypot() function returns square root of sum of squares of two arguments, i.e., sqrt(x2 +y2).

Syntax

double hypot (double x, double y);
float hypotf (float x, float y);
long double hypotl (long double x, long double y);

Parameters

x Specify a value.
y Specify a value.

Return Value

Returns sqrt(x2 +y2).

Example:

In the example below, hypot() function is used to return sqrt(x2 +y2).

#include <stdio.h>
#include <math.h>
 
int main (){
  printf("%lf\n", hypot(3, 4));
  printf("%lf\n", hypot(5, 12));
  printf("%lf\n", hypot(8, 15));  
  return 0;
}

The output of the above code will be:

5.000000
13.000000
17.000000

❮ C <math.h> Library