6.11.167 sin Function
Calculates the trigonometric sine function of a double precision floating-point value.
Include
<math.h>
Prototype
double sin (double b);
Argument
x
- value for which to return the sine
Return Value
Returns the sine of x
specified in radians in the range
. NaN is returned if x
is
.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main(void)
{
double x, y;
errno = 0;
x = -1.0;
y = sin (x);
if (errno)
perror("Error");
printf("The sine of %f is %f\n", x, y);
errno = 0;
x = 0.0;
y = sin (x);
if (errno)
perror("Error");
printf("The sine of %f is %f\n", x, y);
}
Example Output
The sine of -1.000000 is -0.841471
The sine of 0.000000 is 0.000000