Join our newsletter for the latest updates.

C hypot()

The hypotenuse is the longest side of a right-angled triangle. The hypot() function is used to find hypotenuse when other two sides are provided.

hypot() function Prototype

double hypot(double p, double b);

h = √(p2+b2) in mathematics is equivalent to h = hypot(p, b); in C Programming.

The hypot() function is defined in math.h 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;

    hypotenuse = hypot(p, b);

    printf("hypot(%.2lf, %.2lf) = %.2lf", p, b, hypotenuse);

    return 0;


hypot(5.00, 12.00) = 13.00