C cosh() function

C cosh() function - Calculate Hyperbolic Cosine


double cosh(double x)

The cosh() function is used to calculate the hyperbolic cosine of x. The value x is expressed in radians.


Name Description Required /Optional
x Expressed in radians. Required

Return value from cosh()

  • Returns the hyperbolic cosine of x.

Example: cosh() function

The following example shows the usage of cosh() function:

#include <math.h>
#include <stdio.h>
int main(void)
   double x, y;
   x = 0;
   y = cosh(x);
   printf("cosh( %lf ) = %lf\n", x, y);
   x = 1;
   y = cosh(x);
   printf("\ncosh( %lf ) = %lf\n", x, y);
   x = 7.3;
   y = cosh(x);
   printf("\ncosh( %lf ) = %lf\n", x, y);


cosh( 0.000000 ) = 1.000000

cosh( 1.000000 ) = 1.543081

cosh( 7.300000 ) = 740.150302

C Programming Code Editor:

Previous C Programming: C cos()
Next C Programming: C sin()

Follow us on Facebook and Twitter for latest update.

C Programming: Tips of the Day

What's the point of const pointers?

const is a tool which you should use in pursuit of a very important C++ concept:

Find bugs at compile-time, rather than run-time, by getting the compiler to enforce what you mean.

Even though it does not change the functionality, adding const generates a compiler error when you're doing things you didn't mean to do. Imagine the following typo:

void foo(int* ptr)
    ptr = 0;// oops, I meant *ptr = 0

If you use int* const, this would generate a compiler error because you're changing the value to ptr. Adding restrictions via syntax is a good thing in general. Just don't take it too far -- the example you gave is a case where most people don't bother using const.

Ref : https://bit.ly/33Cdn3Q