Popular Tutorials
Start Learning CCertification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
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;
}
Output
hypot(5.00, 12.00) = 13.00
Did you find this article helpful?