C sin() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
math.h

Definition

In C, sin() returns the sine of an angle. The angle is in radians. sin(0) is 0.

You pass one double. The result is a double from -1 to 1. Include <math.h>.

Syntax

Pass the angle in radians. Start with this call.

C
sin(0.0);
CallWhat it does
sin(0.0)Returns 0.

Include <math.h>. On GCC, link with -lm. Convert degrees with rad = deg * acos(-1.0) / 180.0.

Library declarations
C
double sin(double x);
float sinf(float x);
long double sinl(long double x);

Parameters

ParameterDescription
xRequired. The angle in radians.

Return Value

Return ValueDescription
SineA double from -1 to 1.

C Examples

Example 1 — Common Radian Values

Use a portable π and print classic unit-circle results.

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

int main(void) {
    const double PI = acos(-1.0);

    printf("sin(0)    = %.4f\n", sin(0.0));
    printf("sin(PI/6) = %.4f\n", sin(PI / 6.0));
    printf("sin(PI/2) = %.4f\n", sin(PI / 2.0));
    printf("sin(PI)   = %.4f\n", sin(PI));

    return 0;
}

How It Works

  1. Get π. acos(-1.0) is a portable constant for π.
  2. Pass radians. PI/6 is 30°; PI/2 is 90°.
  3. Known results. sin(π/6) = 0.5, sin(π/2) = 1.
  4. Link libm. On GCC, remember -lm.

Example 2 — Convert Degrees Before sin

Never pass degree numbers directly—convert first.

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

int main(void) {
    double deg = 30.0;
    double pi = acos(-1.0);
    double rad = deg * pi / 180.0;

    printf("%.0f deg = %.4f rad\n", deg, rad);
    printf("sin(30 deg) = %.4f\n", sin(rad));

    return 0;
}

How It Works

  1. Start with degrees. Humans often think in 30°, 45°, 90°.
  2. Scale to radians. Multiply by π / 180.
  3. Call sin. Now the argument is correct → 0.5.
  4. Avoid the trap. sin(30) without conversion is 30 radians.

Example 3 — sin with cos

On a unit circle, sin² + cos² = 1. Pair with cos to check.

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

int main(void) {
    double rad = acos(-1.0) / 3.0;  /* 60° */
    double s = sin(rad);
    double c = cos(rad);

    printf("sin = %.4f\n", s);
    printf("cos = %.4f\n", c);
    printf("sin^2 + cos^2 = %.4f\n", s * s + c * c);

    return 0;
}

How It Works

  1. Pick an angle. π/3 is 60°.
  2. Compute both. sin ≈ 0.866, cos ≈ 0.5.
  3. Check identity. Squares sum to about 1.
  4. Unit circle. sin is the y-component; cos is the x-component.

Frequently Asked Questions

sin() returns the sine of an angle in radians. sin(0) is 0.
x is required. It is the angle in radians.
A double from -1 to 1.
Include <math.h>. On GCC, link with -lm.
No. Convert degrees to radians first. 180 degrees is π radians.

Next: sinh()

Learn the hyperbolic sine—similar name, different math.

sinh() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful