sinh() function in C++ STL

C++ProgrammingServer Side Programming

The sinh() function returns the hyperbolic sine of an angle given in radians. It is an inbuilt function in C++ STL.

The syntax of the sinh() function is given as follows.

sinh(var)

As can be seen from the syntax, the function sinh() accepts a parameter var of data type float, double or long double. It returns the hyperbolic sine of var.

A program that demonstrates sinh() in C++ is given as follows.

Example

 Live Demo

#include <iostream>
#include <cmath>
using namespace std;
int main() {
   double d = 5, ans;
   ans = sinh(d);
   cout << "sinh("<< d <<") = " << ans << endl;
   return 0;
}

Output

sinh(5) = 74.2032

In the above program, first the variable d is initialized. Then hyperbolic sine of d is found using sinh() and stored in ans. Finally the value of ans is displayed. This is demonstrated by the following code snippet.

double d = 5, ans;
ans = sinh(d);
cout << "sinh("<< d <<") = " << ans << endl;

If the value is provided in degrees, it is converted to radians before using sinh() function.as it returns the hyperbolic sine of an angle given in radians A program to demonstrate this is as follows.

Example

 Live Demo

#include <iostream>
#include <cmath>
using namespace std;
int main() {
   double degree = 60, ans;
   degree = degree * 3.14159/180;
   ans = sinh(degree);
   cout << "sinh("<<degree<<") = "<< ans << endl;
   return 0;
}

Output

sinh(1.0472) = 1.24937

In the above program, the value is given in degree. So it is converted into radians and then the hyperbolic sine is obtained using sinh(). Finally, the output is displayed. This is demonstrated by the following code snippet.

double degree = 60, ans;
degree = degree * 3.14159/180;
ans = sinh(degree);
cout << "sinh("<<degree<<") = " << ans << endl;
raja
Published on 05-Oct-2018 13:43:52
Advertisements