The function double sin(double x); returns the sine of x, expressed in radians.
Function prototype of sin
double sin(double x);
- x : A floating point value representing an angle in radians.
Return value of sin
It returns the sine of x.
C program using sin function
The following program shows the use of sin function to calculate sine of an angle.
#include <stdio.h> #include <math.h> #define PI 3.14159 int main(){ double value, radian, degree; printf("Enter an angle in degree\n"); scanf("%lf", °ree); /* * Degree to radian conversion * One degree is equal to PI/180 radians. * Where PI = 22/7 = 3.14159(approx) */ radian = degree * (PI/180.0); value = sin(radian); printf("The sine of %lf is %lf\n", degree, value); return 0; }
Output
Enter an angle in degree 30 The sine of 30.000000 is 0.500000
Enter an angle in degree 90 The sine of 90.000000 is 1.000000