function
<cmath> <ctgmath>

tan

double tan (double x);
     double tan  (double x);
      float tanf (float x);
long double tanl (long double x);
     double tan (double x);
      float tan (float x);
long double tan (long double x);
     double tan (double x);
      float tan (float x);
long double tan (long double x);
     double tan (T x);           // additional overloads for integral types
Compute tangent
Returns the tangent of an angle of x radians.

Header <tgmath.h> provides a type-generic macro version of this function.
This function is overloaded in <complex> and <valarray> (see complex tan and valarray tan).
Additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations (defined for T being any integral type).

This function is also overloaded in <complex> and <valarray> (see complex tan and valarray tan).

Parameters

x
Value representing an angle, expressed in radians.
One radian is equivalent to 180/PI degrees.

Return Value

Tangent of x radians.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* tan example */
#include <stdio.h>      /* printf */
#include <math.h>       /* tan */

#define PI 3.14159265

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


Output:

The tangent of 45.000000 degrees is 1.000000.

See also