C Language: cosh function(Hyperbolic Cosine)

C Programming allows us to perform mathematical operations through the functions defined in header file. The header file contains various methods for performing mathematical operations such as sqrt(), pow(), ceil(), floor() etc.

C Math Functions

In the C Programming Language, the cosh function returns the hyperbolic cosine of x.

Syntax

The syntax for the cosh function in the C Language is:




double cosh(double x);



Parameters or Arguments

A value expressed in radians (not degrees).

Returns

The cosh function returns the hyperbolic cosine of x. If the magnitude of x is too large, the cosh function will return a range error.

Required Header

In the C Language, the required header for the cosh function is




#include <math.h>



Applies To

In the C Language, the cosh function can be used in the following versions

  • ANSI/ISO 9899-1990

cosh Example




/* Example using cosh by c programming */

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

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the cosh of */
    value = 0.5;

    /* Calculate the Hyperbolic Cosine of value */
    result = cosh(value);

    /* Display the result of the calculation */
    printf("The Hyperbolic Cosine of %f is %f\n", value, result);

    return 0;
}



When compiled and run, this application will output

The Hyperbolic Cosine of 0.500000 is 1.127626




Instagram