cos - C math.h

C examples for math.h:cos

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Returns the cosine of an angle of x radians.

Prototype

long double cosl (long double x);
long double cos (long double x);
     double cos (double x);
      float cosf (float x);
      float cos (float x);
     double cos (T x);           

Parameters

Parameter Description
x Value representing an angle expressed in radians.

Return Value

Cosine of x radians.

Example

Demo Code

#include <stdio.h>
#include <math.h> /* cos */

#define PI 3.14159265//from  ww  w .  j a  v  a2s  .  c o  m

int main ()
{
  double param = 60.0;
  double result = cos ( param * PI / 180.0 );
  printf ("The cosine of %f degrees is %f.\n", param, result );
  return 0;
}

Related Tutorials