December 2005
Beginner to intermediate
618 pages
20h 19m
English
sin
Calculates the sine of an angle
#include <math.h> doublesin( doublex); doublesinf( floatx); (C99) doublesinl( long doublex); (C99)
The sin() function
calculates the sine of the angle represented by its argument
x as a number of radians. The return
value is in the range -1 ≤
sin(x) ≤ 1.
#define DEG_PER_RAD ( 180.0 / PI )
const double PI = 4.0 * atan( 1.0 );
double a[4];
printf( "\nEnter an acute angle measure, in degrees: " );
if ( scanf( "%lf", a ) < 1 || ( a[0] <= 0 || a[0] >= 90 ) )
printf( "\nThat's not an acute angle.\n" ), exit( 1 );
else
{
a[1] = a[0] + 90 ;
a[2] = 180 − a[0] ;
a[3] = 225 + a[0] ;
for ( int i = 0 ; i < 4 ; i ++ )
printf( "The sine of %4.2lf degrees is %6.4lf.\n",
a[i], sin( a[i] / DEG_PER_RAD ) );
}Read now
Unlock full access