Use trigonometric functions - C Function

C examples for Function:Math Function

Introduction

Some of trigonometric functions from math.h are shown in the following table.

FunctionOperation
sin(x) Sine of x expressed in radians
cos(x) Cosine of x
tan(x) Tangent of x

float and type long double have f or l, respectively, appended to the name.

Arguments and values returned are of type float, type double, or type long double and angles are expressed in radians.

Demo Code

#include <stdio.h> 
#include <math.h>
int main(void) { 

    double angle = 45.0;                        // Angle in degrees
    double pi = 3.14159265;
    double sine = 0.0;
    double cosine = 0.0;
    //from www  .  j a va2  s .com
    sine = sin(pi*angle/180.0);                 // Angle converted to radians
    cosine = sin(pi*angle/180.0);               // Angle converted to radians
    
    printf("%d",sine);
    return 0; 
}

Related Tutorials