Easy Tutorial
❮ C Strings C Examples Leap Year ❯

C Library Function - sin()

C Standard Library - <math.h>

Description

The C library function double sin(double x) returns the sine of the radian angle x.

Declaration

Here is the declaration for the sin() function.

double sin(double x)

Parameters

Return Value

This function returns the sine of x.

Example

The following example demonstrates the use of the sin() function.

#include <stdio.h>
#include <math.h>

#define PI 3.14159265

int main ()
{
   double x, ret, val;

   x = 45.0;
   val = PI / 180;
   ret = sin(x*val);
   printf("%lf 的正弦是 %lf 度", x, ret);

   return(0);
}

Let's compile and run the above program, which will produce the following result:

45.000000 的正弦是 0.707107 度

C Standard Library - <math.h>

❮ C Strings C Examples Leap Year ❯