Ads by ProfitSence
Close

C++ cosh()

Last Updated on Wednesday 5th Oct 2022

cosh

The C++ cosh() function returns the hyperbolic cosine of an angle given in radians. and it takes a single argument.The function is defined in <cmath> header file.

Syntax

			
					 cosh(x)

			
	

Parameters

The cosh() function takes a one argument which is a hyperbolic angle in radians.

Return value

Returns the hyperbolic cosine of the argument.

If the magnitude of the result is too large to be represented by a value of the return type, the function returns HUGE_VAL with the proper sign, and an overflow range error occurs.

cosh function

cosh() prototype [As of C++ 11 standard]

			
					double cosh(double x);
float cosh(float x);
long double cosh(long double x);
double cosh(T x); // For integral type.

			
	

Example 1: C++ cosh()

			
					#include <stdio.h>
#include <math.h>

int main () {
  double param, result;
  param = log(4.0);
  result = cosh (param);
  printf ("The hyperbolic cosine of %f is %f.\n", param, result );
  return 0;
}

			
	

Output

			
					The hyperbolic cosine of 1.386294 is 2.125000.

			
	

cosh math

Example 2 : C++ cosh()

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

int main() {
    double x = 2.44, result;
    result = cosh(x);
    cout << "cosh(x) = " << result << endl;
    double xDegrees = 90;
    x = xDegrees * 3.14159/180;
    result = cosh(x);
    cout << "cosh(x) = " << result << endl;

    return 0;
}

			
	

Output

			
					cosh(x) = 5.7801
cosh(x) = 2.50918