sin()

Published Oct 8, 2022Updated Jun 20, 2023
Contribute to Docs

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

Codebyte Example

The following code example returns the sine of a angle given in radians using the sin() function.

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn C++ on Codecademy