📜  C++ STL-math.sin()函数

📅  最后修改于: 2020-10-18 11:35:00             🧑  作者: Mango

C++ STL 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 
#include
using namespace std;
int main()
{
  double degree=60;
  double radian=degree*3.14/180;
  cout<<"Sine of an angle is : "<

输出:

Sine of an angle is : 0.86576   

在此示例中,当度数等于60时,sin()函数计算角度的正弦值。

例子2

让我们看一个简单的例子,当x的值为负数时。

#include 
#include
using namespace std;
int main()
{
  double degree= -50;
  double radian=degree*3.14/180;
  cout<<"Sine of an angle is : "<

输出:

Sine of an angle is : -0.76576 

在他的示例中,sin()函数在度的值为负(即-50)时找到角度的正弦值。