In this C++ tutorial, you will learn how to find hyperbolic cosine of given angle using cosh() function of cmath, with syntax and examples.

C cosh

C++ cosh() returns hyperbolic cosine of angle given in radians.

Syntax

The syntax of C++ cosh() is

cosh(x)

where

Parameter Description
x A double, float, long double, or integral type value representing angle in radians.

Returns

The return value depends on the type of value passed for parameter x.

The return value of cosh(x) is

  • double if x is double or IntegralType.
  • float if x is float.
  • long double if x is long double.

The synopsis of cosh() function is

double cosh(double x);
float cosh(float x);
long double cosh(long double x);
double cosh(T x); // for integral type argument values

cosh() is a function of cmath library. Include cmath library at the start of program, if using cosh() function.

Example

In this example, we

C++ Program

#include <iostream>
#include<cmath>
using namespace std;

int main() {
    double x;
    cout << "Enter angle (radians) : ";
    cin >> x;
    
    double result = cosh(x);
    cout << "cosh(" << x << ") : " << result << endl;
}

Output

Enter angle (radians) : 2
cosh(2) : 3.7622
Program ended with exit code: 0
Enter angle (radians) : 0
cosh(0) : 1
Program ended with exit code: 0
Enter angle (radians) : -2
cosh(-2) : 3.7622
Program ended with exit code: 0

Conclusion

In this C++ Tutorial, we learned the syntax of C++ cosh(), and how to use this function to find the hyperbolic cosine of given angle, with the help of examples.