Format
#include <math.h> double cos(double x);
Language Level: ANSI, POSIX, XPG4
cos calculates the cosine of x. The value x
is expressed in radians. If x is too large, a partial
loss of significance in the result may occur.
Return Value
cos returns the cosine of x.
Example
This example calculates y to be the cosine of
x.
#include <math.h> #include <stdio.h>
int main(void)
{
double x, y;
x = 7.2; y = cos(x);
printf("cos( %lf ) = %lf\n", x, y);
/***************************************
The output should be:
cos( 7.200000 ) = 0.608351 ***************************************/ }
![]()
acos -- Calculate Arccosine
cosh -- Calculate Hyperbolic Cosine
_facos -- Calculate Arccosine
_fcos -- Calculate Cosine
_fcossin -- Calculate Cosine and Sine
_fsincos -- Calculate Sine and Cosine
sin -- Calculate Sine
sinh -- Calculate Hyperbolic Sine
tan -- Calculate Tangent
tanh -- Calculate Hyperbolic Tangent
<math.h>