English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The hypotenuse is the longest side of a right-angled triangle. When the other two sides are provided, the hypot() function is used to calculate the length of the hypotenuse of a right-angled triangle.
double hypot(double p, double b);
In mathematics, h = √(p2+b2) is equivalent to the C language programming h = hypot(p, b);.
The hypot() function inmath.h Defined in the header file
#include <stdio.h> #include <math.h> int main() { double p, b; double hypotenuse; p = 5.0; b = 12.0; The hypotenuse is calculated as hypot(p, b); printf("hypot(%.2lf, %.2lf) = %.2lf", p, b, hypotenuse); return 0; }
Output Result
hypot(5.00, 12.00) = 13.00