C math library function cosh()


In this tutorial, you will learn about C math library function cosh() that computes the hyperbolic cosine of the argument.

C math library function cosh()

 

cosh() is the standard C math library function that is defined in math library math.h.

#include<math.h>

Function prototype of C math library function cosh()

double cosh( double x );

where,

x = angle in radians ( floating point value )

Return Value of cosh()

This function returns the hyperbolic cosine value of x.

The return type is double.

Example: Program to demonstrate the use of C math library function cosh( )

/*Use of math library function cosh()*/

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

int main()
{
   double x ;

   x = 0.3;

   //calculation of hyperbolic cosine
   printf("\ncosh( %.3lf ) = %.3lf \n", x, cosh( x ));

   x = -0.5;
   //calculation of hyperbolic cosine
   printf("\ncosh( %.3lf ) = %.3lf \n", x, cosh( x ));

   x = 1.5;
   //calculation of hyperbolic cosine
   printf("\ncosh( %.3lf ) = %.3lf \n", x, cosh( x ));

 return 0;
}

Output

c function cosh

 

Explanation

In the above program, we have calculated the hyperbolic cosine of x.