cos


cos

Calculates the cosine of an angle

 #include <math.h> double cos ( double x  ); double cosf ( float x  );         (C99) double cosl ( long double x  );         (C99) 

The cos( ) function returns the cosine of its argument, which is an angle measure in radians. The return value is in the range -1 cos(x) 1.

Example

 /*  * Calculate the sloping width of a roof  * given the horizontal width  * and the angle from the horizontal.  */ #define PI 3.141593 #define DEG_PER_RAD (180.0/PI) double roof_pitch = 20.0;            // In degrees double floor_width = 30.0;           // In feet, say. double roof_width = 1.0 / cos( roof_pitch / DEG_PER_RAD ) * floor_width; printf( "The sloping width of the roof is %4.2f ft.\n", roof_width ); 

This code produces the following output:

 The sloping width of the roof is 31.93 ft. 

See Also

sin( ), tan( ), acos( ), ccos( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net