Name
tan
Synopsis
Calculates the tangent of an angle
#include <math.h> doubletan
( doublex
); floattanf
( floatx
); (C99) long doubletanl
( long doublex
); (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.
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.