cos() - math.h
The C library function double cos(double x) returns the cosine of a radian angle x.
Syntax
double cos(double x)
Example
#include
#include
#define PI 3.14159265
int main ()
{
double x, ret, val;
x = 60.0;
val = PI / 180.0;
ret = cos( x*val );
printf("The cosine of %lf is %lf degrees\n", x, ret);
x = 90.0;
val = PI / 180.0;
ret = cos( x*val );
printf("The cosine of %lf is %lf degrees\n", x, ret);
return(0);
}
Output / Return Value
The cosine of 60.000000 is 0.500000 degrees
The cosine of 90.000000 is 0.000000 degrees
Limitations
Alternatives / See Also
Reference