In C++, the sin()
function is used to return the sine of an angle of the argument x
passed to it.
double sin(double x);
float sin(float x);
long double sin(long double x);
The sin()
function takes only one parameter value x
, which represents the value whose sine of angle in radian is to be determined.
The sin()
function returns the sine of the angle in radian of the value of the parameter passed to it.
#include <iostream>#include <cmath>using namespace std;int main(){// creating the variablesint x = 90;double result;// implementing the sin() functionresult = sin(x);cout << "sin(90) = " << result << endl;return 0;}
Lines 8–9: We create variables x
and result
.
Line 12: We implement the sin()
function on the x
variable and assign the value to the result
variable.
Line 13: We print the result
variable.