English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

C library function hypot() usage and example

C Standard Library <math.h>

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.

hypot() function prototype

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

Example: C hypot() function

#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

C Standard Library <math.h>