C++ <cmath> - hypot() Function
The C++ <cmath> hypot() function returns square root of sum of squares of two arguments, i.e., sqrt(x2 +y2).
Syntax
double hypot (double x, double y); float hypot (float x, float y); long double hypot (long double x, long double y); double hypot (Type1 x, Type2 y);
Parameters
x |
Specify a value. |
y |
Specify a value. |
Return Value
Returns sqrt(x2 +y2).
Example:
In the example below, hypot() function is used to return sqrt(x2 +y2).
#include <iostream> #include <cmath> using namespace std; int main (){ cout<<hypot(3, 4)<<"\n"; cout<<hypot(5, 12)<<"\n"; cout<<hypot(8, 15)<<"\n"; return 0; }
The output of the above code will be:
5 13 17
❮ C++ <cmath> Library