C++ Math sin
The function is utilized to calculate the sine of an angle provided in radians.
Syntax
Consider a radian 'x'. Syntax would be:
float sin(float x);
float sin(double x);
float sin(long double x);
double sin(integral x);
Note: If the value passed is an integer type, then it is cast to double.
Parameter
x : The value specified in terms of radian.
Return value
It provides the sine value of an angle specified in radians within the interval of [-1, 1].
Example 1
Let's observe a basic scenario where the value of x is greater than zero.
#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;
}
Output:
Sine of an angle is : 0.86576
In this instance, the sin function computes the sine value of an angle with a measurement of 60 degrees.
Example 2
Let's examine a basic scenario where the value of x is below zero.
#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;
}
Output:
Sine of an angle is : -0.76576
In the provided illustration, the sin function calculates the sine of an angle in cases where the degree value is negative, such as -50.