The function double cos(double x); returns the cosine of x, expressed in radians.
Function prototype of cos
double cos(double x);
- x : A floating point value representing an angle in radians.
Return value of cos
It returns the cosine of x.
C program using cos function
The following program shows the use of cos function to calculate cosine of an angle.

#include <stdio.h>
#include <math.h>
#define PI 3.14159
int main(){
double value, radian, degree;
printf("Enter an angle in degree\n");
scanf("%lf", °ree);
/*
* Degree to radian conversion
* One radian is equal to 180/PI degrees.
*/
radian = degree * (PI/180.0);
value = cos(radian);
printf("The cosine of %lf is %0.4lf\n", degree, value);
return 0;
}
Output
Enter an angle in degree 45 The cosine of 45.0000 is 0.7071
Enter an angle in degree 180 The cosine of 180.0000 is -1.0000