December 2005
Beginner to intermediate
618 pages
20h 19m
English
tan
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.
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.
Read now
Unlock full access