Saturday, April 6, 2013

cos in c - math.h

Cos function returns cosine of an angle(in radian).
1 radian = 57.2958(approximately).
Declaration: double cos(double);

C programming code

#include <stdio.h>
#include <math.h>
 
int main()
{
  double result, x = 1.0471;
 
  result = cos(x);
 
  printf("cos(%.4lf) = %.2lf\n", x, result);
 
  return 0;
}
Compiler used: 
GCC
Output of program: 
cos

No comments:

Post a Comment