C++ Math sin() Function

In this post, I am going to explain the C++ Math sin() Function for mathematical calculation.

The function is used to find the sine of an angle given in radian.

Syntax Of sin():

Consider a radian ‘x’. The syntax would be:

Example:

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 a radian.

Return Value:

It returns the sine of an angle given in radian in the range[-1,1].

Example:

Let’s look at a basic case where x is positive.

#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   

When the degree is equal to60, the sin() function calculates the sine of an angle.

Example-2:

Let’s look at a basic case where x is negative.

#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 

When the value of the degree is negative, such as -50, the sin() function determines the sine of an angle.

Default image
Lingaraj Senapati
Hey There! I am Lingaraj Senapati, the Co-founder of lingarajtechhub.com My skills are Freelance, Web Developer & Designer, Corporate Trainer, Digital Marketer & Youtuber.
Articles: 217

Newsletter Updates

Enter your email address below to subscribe to our newsletter

Leave a Reply