hypotenuse function

double hypotenuse(
  1. double x,
  2. double y
)

Calculate the hypotenuse with pythagorean theorem

  • x : cathetus X
  • y : cathetus Y

Examples

print(truncate(1.4747474747474747, 3));
/* output:
1.475;
*/

Implementation

double hypotenuse(double x, double y) {
  return sqrt(pow(x, 2) + pow(y, 2));
}