Previous Page
Next Page

tan

Calculates the tangent of an angle

#include <math.h>
double tan ( double x  );
float tanf ( float x  );         (C99)
long double tanl ( long double x  );         (C99)

The tan( ) function calculates the tangent of the angle represented by its argument x as a number of radians.

Example

const double pi = 4.0L * atan( 1.0 );         // Because tan(pi/4) = 1
double shadow_length = 85.5,
       angle = 36.2;          // Sun's elevation from the horizon, in
                              // degrees
double height = shadow_length * tan( angle * pi/180);

printf("The tower is %.2f meters high.\n", height);

This code produces the following output:

The tower is 62.58 meters high.

See Also

sin( ), cos( ), atan( ); the tangent functions for complex numbers, ctan( ), ctanf( ) and ctanl( )


Previous Page
Next Page