English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

Usage and Example of C Library Function sin()

C Standard Library - <math.h>

C Library Function double sin(double x) Returns the radian angle x sine.

Declaration

Below is the declaration of the sin() function.

double sin(double x)

Parameter

  • x  -- A floating-point value representing an angle in radians.

Return Value

This function returns the sine of x.

Online Example

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

#include <stdio.h>
#include <math.h>
int main()
{
    double x;
    double result;
    x = 2.3;
    result = sin(x);
    printf("sin(%.2lf) sine is = %.2lf degree, x, result);
    x = -2.3;
    result = sin(x);
    printf("sin(%.2lf) sine is = %.2lf degree, x, result);
    x = 0;
    result = sin(x);
    printf("sin(%.2lf) sine is = %.2lf degree, x, result);
    return 0;
}

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

sin(2.3The sine of 0) is = 0.75 degrees
sin(-2.3The sine of 0) is = -0.75 degrees
The sine of 0.00 is = 0.00 degrees

C Standard Library - <math.h>