The C sin Function is a C Math Library Function, used to calculate the Trigonometry Sine value for the specified expression. The syntax of the sin in C Programming is
double sin(double number);
The SIN function in C will return the value between -1 and 1. Before we get into the syntax of a SIN function in C, Let us see the mathematical formula behind this Trigonometry Sine function:
sin(x) = Length of the Opposite Side / Length of the Hypotenuse
SIN Function in C Example
The sin function in the math library allows you to calculate the trigonometric Sine for the specified values. This program, ask the user to enter his/her own value, and then it will find the sine value of the user-specified value
TIP : Please refer to the C ASIN Function article to calculate the Arc Sine of a specified expression.
/* Example for SIN Function in C Programming */ #include <stdio.h> #include <math.h> int main() { double sinValue, number; printf(" Please Enter the Value to calculate Sine : "); scanf("%lf", &number); sinValue = sin(number); printf("\n The Sine value of %lf = %f ", number, sinValue); return 0; }
C SINE Function Example 2
This C Programming example allow the user to enter the value in degrees, and then we are converting the degrees to Radians. And finally, we are finding the sine value of the radian
/* Example for SIN Function in C Programming */ #include <stdio.h> #include <math.h> #define PI 3.14159 int main() { double sinValue, radianVal, degreeVal; printf(" Please Enter an Angle in degrees : "); scanf("%lf", °reeVal); // Convert Degree Value to Radian radianVal = degreeVal * (PI/180); sinValue = sin(radianVal); printf("\n The Sine value of %f = %f ", degreeVal, sinValue); return 0; }