C Standard Library

C <math.h> - sin() Function



The C <math.h> sin() function returns trigonometric sine of an angle (angle should be in radians). In the graph below, sin(x) vs x is plotted.

Sin Function

Syntax

double sin (double x);
float sinf (float x);
long double sinl (long double x);

Parameters

x Specify the angle in radian.

Return Value

Returns the trigonometric sine of an angle.

Example:

In the example below, sin() function is used to find out the trigonometric sine of an angle.

#include <stdio.h>
#include <math.h>
 
int main (){
  //M_PI - value of PI from math.h
  printf("%lf\n",sin(M_PI/6));
  printf("%lf\n",sin(M_PI/4));
  printf("%lf\n",sin(M_PI/3));
  return 0;
}

The output of the above code will be:

0.500000
0.707107
0.866025

❮ C <math.h> Library