In this tutorial, you will learn about C math library function sin() that computes the sine of the argument.
sin()
is the built in standard math library function that is defined in math library math.h
.
#include<math.h>
double sin( double x );
where,
x = angle in radians ( floating point value )
This function returns the sine value of x.
The return type is double and ranges between 1 and -1.
/*Use of math library function cos()*/
#include<stdio.h>
#include<math.h>
#define PI 3.1415926
int main()
{
double x ;
x = 45;
//calculation of sine
printf("\nsin( %.3lf ) = %.3lf\n", x, sin( (x * PI) / 180 ));
x = 90;
//calculation of sine
printf("\nsin( %.3lf ) = %.3lf\n", x, sin( (x * PI) / 180 ));
x = 120;
//calculation of sine
printf("\nsin( %.3lf ) = %.3lf\n", x, sin( (x * PI) / 180 ));
return 0;
}
Output
Explanation
In the above program, we have calculated the sine of x
.