Calculates the inverse cosine of a number #include <math.h> double acos ( double x ); float acosf ( float x ); (C99) long double acosl ( long double x ); (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 domainthat is, greater than 1 or less than -1the function incurs a domain error. The return value is given in radians, and is thus in the range 0 acos(x) p. Example/* * 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. See AlsoThe arc cosine functions for complex numbers: cacos( ), cacosf( ), and cacosl( ) |