×

C++ Tutorial

C++ Data types

C++ Operators & Keywords

C++ Conditional Statements

C++ Functions

C++ 'this' Pointer, References

C++ Class & Objects

C++ Constructors & Destructors

C++ Operator overloading

C++ 11 (Advance C++)

C++ Preparation

C++ Header Files & Functionsr

Data Structure with C++

C++ - Miscellaneous

C++ Programs

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

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.

Sample Input and Output

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

Example

// 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!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.