SIN Function in C

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 C SIN function is

double sin(double number);

The SIN function will return a 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:

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 asks 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.

#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;
}
SIN Function in C programming 1

C SINE Function Example 2

This C Programming example allows the user to enter the value in degrees, and then we convert the degrees to Radians. And finally, we are finding the sine value of the radian.

#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", &degreeVal);
  
  // Convert Degree Value to Radian 
  radianVal = degreeVal * (PI/180);
  sinValue = sin(radianVal);
  
  printf("\n The Sine value of %f = %f ", degreeVal, sinValue);
  
  return 0;
}
 Please Enter an Angle in degrees :  30

 The Sine value of 30.000000 = 0.500000