Home » C++ programming language

cosh() function with example in C++

C++ cosh() function: Here, we are going to learn about the cosh() function with example of cmath header in C++ programming language?
Submitted by IncludeHelp, on April 28, 2019

C++ cosh() function

cosh() function is a library function of cmath header, it is used to find the hyperbolic cosine of the given value (hyperbolic angle), it accepts a number (x) and returns the hyperbolic cosine of x.

Syntax of cosh() function:

    cosh(x);

Parameter(s): x – is the number (hyperbolic angel) to be used to calculate the hyperbolic cosine.

Return value: double – it returns double type value that is the hyperbolic cosine of hyperbolic angle x.

Example:

    Input:
    float x = 2.45;
    
    Function call:
    cosh(x);    
    
    Output:
    5.83732

C++ code to demonstrate the example of cosh() function

// C++ code to demonstrate the example of 
// cosh() function

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

// main() section
int main()
{
    float x;
    
    x = -10.23;
    cout<<"cosh("<<x<<"): "<<cosh(x)<<endl;

    x = 0;
    cout<<"cosh("<<x<<"): "<<cosh(x)<<endl;    

    x = 2.45;
    cout<<"cosh("<<x<<"): "<<cosh(x)<<endl;    
    
    return 0;
}

Output

cosh(-10.23): 13861.2
cosh(0): 1
cosh(2.45): 5.83732

Reference: C++ cosh() function






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.