December 2005
Beginner to intermediate
618 pages
20h 19m
English
acos
Calculates the inverse cosine of a number
#include <math.h> doubleacos( doublex); floatacosf( floatx); (C99) long doubleacosl( long doublex); (C99)
acos() implements the
inverse cosine function, commonly called arc cosine. The argument
x must be between −1 and 1, inclusive: −1
≤ x ≤ 1. If x
is outside the function’s domain—that is, greater than 1 or less
than −1—the function incurs a domain error.
The return value is given in radians, and is thus in the range
0 ≤ acos(x) ≤ π.
/*
* Calculate the pitch of a roof given
* the sloping width from eaves to ridge and
* the horizontal width of the floor below it.
*/
#define PI 3.141593
#define DEG_PER_RAD (180.0/PI)
double floor_width = 30.0;
double roof_width = 34.6;
double roof_pitch =acos( floor_width / roof_width ) * DEG_PER_RAD ;
printf( "The pitch of the roof is %2.0f degrees.\n", roof_pitch );This code produces the following output:
The pitch of the roof is 30 degrees.
The arc cosine functions for complex numbers: cacos(), cacosf(), and cacosl()
Read now
Unlock full access