What is the cosh() function in C++?
Overview
The cosh() function in C++ is used to return the hyperbolic cosine of an angle given in radians.
Mathematically:
Cosh(x) =
Syntax
double cosh(double x);
float cosh(float x);
long double cosh(long double x);
Parameter value
The cosh() function takes a single argument x, which represents the hyperbolic angle in radians.
Return value
The cosh() function returns the hyperbolic cosine of the argument passed to it.
Example
#include <iostream>#include <cmath>using namespace std;int main(){// creating a variabledouble x = 5.25, result;// applying the cosh() functionresult = cosh(x);// printing our outputcout << "cosh(x) = " << result << endl;return 0;}
Explanation
- In line 6, we declare a variable
x. - In line 10, we call the
cosh()function for the variablexand assign the output to a new variableresult. - In line 13, we print the variable
result.