C Standard Library

C <math.h> - tan() Function



The C <math.h> tan() function returns trigonometric tangent of an angle (angle should be in radians). In the graph below, tan(x) vs x is plotted.

Tan Function

Syntax

double tan (double x);
float tanf (float x);
long double tanl (long double x);

Parameters

x Specify the angle in radian.

Return Value

Returns the trigonometric tangent of an angle.

Example:

In the example below, tan() function is used to find out the trigonometric tangent of an angle.

#include <stdio.h>
#include <math.h>
 
int main (){
  //M_PI - value of PI from math.h
  printf("%lf\n",tan(M_PI/6)); 
  printf("%lf\n",tan(M_PI/4));
  printf("%lf\n",tan(M_PI/3));
  return 0;
}

The output of the above code will be:

0.577350
1.000000
1.732051

❮ C <math.h> Library