C examples for Function:Math Function
Some of trigonometric functions from math.h are shown in the following table.
Function | Operation |
---|---|
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.
#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; }