C++ cmath sin() function
Example
Return the sine of different angles:
const double PI = 3.141592653589793;
cout << sin(3);
cout << sin(-3);
cout << sin(0);
cout << sin(PI);
cout << sin(PI / 2.0);
Try it Yourself »
Definition and Usage
The sin() function returns the sine of an angle.
The sin() function is defined in the <cmath> header file.
Note: Angles are measured in radians.
Tip: It is convenient to create a constant for PI so that you can use fractions of PI for angles. Some implementations of the <cmath> library include a constant M_PI but it is not guaranteed to be available.
Syntax
One of the following:
sin(double angle);
sin(float angle);
Parameter Values
| Parameter | Description |
|---|---|
| angle |
Required. An angle in radians to find the sine of. If this is an integer type then it will be treated as a double.
|
Technical Details
| Returns: | A float value (if the argument is float) or double value (in any other case) representing the sine of an angle. |
|---|