cos() — Calculate Cosine
Format
#include <math.h>
double cos(double x);
Language Level
ANSI
Threadsafe
Yes
Description
The cos()
function
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 might occur.
Return Value
The cos()
function
returns the cosine of x. The value of errno
can be set to either EDOM or ERANGE.
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);
}
/********************* Output should be similar to: *******************
cos( 7.200000 ) = 0.608351
*/