Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <math.h>
double cos(double x);
float cos(float x); /* C++ only */
long double cos(long double x); /* C++ only */
float cosf(float x);
long double cosl(long double x);
Returns the calculated value.
If x is outside prescribed limits, the value is not calculated. Instead, the function returns 0 and sets the errno to ERANGE. If the correct value would cause an underflow, zero is returned and the value ERANGE is stored in errno.
⁄* CELEBC26
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);
}
cos( 7.200000 ) = 0.608351