C cos() function

C cos() function - arc cosine functions


double cos(double x)

The cos() function is used to calculate 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.


Name Description Required /Optional
x Represent an angle expressed in radians. Required

Return value from cos()

  • The function returns the cosine of x.

Example: cos() function

The following example shows the usage of cos() function.

#include <math.h>
#include <stdio.h>
int main(void)
   double x, y;
   x = 0;
   y = cos(x);
   printf("cos( %lf ) = %lf\n", x, y);
   x = 1;
   y = cos(x);
   printf("\ncos( %lf ) = %lf\n", x, y);
   x = 45;
   y = cos(x);
   printf("\ncos( %lf ) = %lf\n", x, y);


cos( 0.000000 ) = 1.000000

cos( 1.000000 ) = 0.540302

cos( 45.000000 ) = 0.525322 

C Programming Code Editor:

Previous C Programming: C atan2()
Next C Programming: C cosh()

Follow us on Facebook and Twitter for latest update.