C++ Math sin()
C++ Math sin()
该函数用于查找以弧度表示的角度的正弦。
语法
考虑一个弧度" x"。语法为:
float sin(float x);
float sin(double x);
float sin(long double x);
double sin(integral x);
注意: 如果传递的值是整数类型,则将其强制转换为double。
参数
x : 以弧度表示的值。
返回值
它返回以弧度给出的在[-1,1]范围内的角度的正弦值。
示例1
让我们看一个简单的示例,当x的值为正时。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
double degree=60;
double radian=degree*3.14/180;
cout<<"Sine of an angle is : "<<sin(radian);
return 0;
}
输出:
Sine of an angle is : 0.86576
在此示例中,当度数等于60时,sin()函数计算角度的正弦。
示例2
x的值为负时的简单示例。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
double degree=-50;
double radian=degree*3.14/180;
cout<<"Sine of an angle is : "<<sin(radian);
return 0;
}
输出:
Sine of an angle is :-0.76576
在他的示例中,当度数的值为负(即-50)时,sin()函数将查找角度的正弦。