该cosh()函数返回以弧度给出的角度的双曲余弦值。它是C ++ STL中的内置函数。
该cosh()函数的语法如下。
cosh(var)
从语法可以看出,该函数cosh()接受数据类型为float,double或long double的参数var。它返回var的双曲余弦值。
cosh()用C ++演示的程序如下-
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double d = 5, ans;
ans = cosh(d);
cout << "cosh("<< d <<") = " << ans << endl;
return 0;
}输出结果
cosh(5) = 74.2099
在上面的程序中,首先将变量d初始化。然后使用找出d的双曲余弦cosh()并将其存储在ans中。最后,显示ans的值。下面的代码片段对此进行了演示。
double d = 5, ans;
ans = cosh(d);
cout << "cosh("<< d <<") = " << ans << endl;如果以度为单位提供值,则在使用cosh()函数之前将其转换为弧度。因为它返回以弧度给出的角度的双曲余弦值。
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double degree = 60, ans;
degree = degree * 3.14159/180;
ans = cosh(degree);
cout << "cosh("<<degree<<") = " << ans << endl;
return 0;
}输出结果
cosh(1.0472) = 1.60029
在上述程序中,该值以度为单位。因此将其转换为弧度,然后使用来获得双曲余弦cosh()。最后,显示输出。下面的代码片段对此进行了演示。
double degree = 60, ans;
degree = degree * 3.14159/180;
ans = cosh(degree);
cout << "cosh("<<degree<<") = " << ans << endl;