sin()

The sin() function returns the sine of an angle argument, given in radians, in the range [-1,1].

Syntax

sin(angle)

The angle parameter is expressed in radians.

Example

The following example illustrates the sin() function:

#include<iostream>
#include<math.h>
using namespace std;
int main() {
// convert degrees to radians
double pi = M_PI;
double degree = 60;
double radian = degree * pi/180;
cout << "Sine of 60 degrees is " << sin(radian) << "\n";
return 0;
}

This results in the following output:

Sine of 60 degrees is 0.866025

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn C++ on Codecademy