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 radiansdouble 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.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C++ on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn C++
Learn C++ — a versatile programming language that’s important for developing software, games, databases, and more.Beginner Friendly11 hours