Calculate the arccosine.
#include <math.h>
#include <errno.h> | Required for definition of errno constant |
double acos( double x );
long double _acosl( long double x );
x | Value whose arccosine is to be calculated |
The acos functions return the arccosine of x in the range 0 to p radians. The value of x must be between Ô1 and 1. The _acosl function is the 80-bit counterpart, which uses an 80-bit, 10-byte coprocessor form of arguments and return values. See the reference page on the long double functions for more details on this data type.
The acos functions return the arccosine result. If x is less than –1 or greater than 1, the function sets errno to EDOM, prints a _DOMAIN error message to stderr, and returns 0. Error handling can be modified with the _matherr (or _matherrl) routine.
acos
Standards:ANSI, UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
_acosl
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
asin functions, atan functions, cos functions, _matherr, sin functions, tan functions
/* ASINCOS.C: This program prompts for a value in the range -1 to 1.
* Input values outside this range will produce _DOMAIN error messages.
* If a valid value is entered, the program prints the arcsine and the
* arccosine of that value.
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
void main( void )
{
double x, y;
printf( "Enter a real number between -1 and 1: " );
scanf( "%lf", &x );
y = asin( x );
printf( "Arcsine of %f = %f\n", x, y );
y = acos( x );
printf( "Arccosine of %f = %f\n", x, y );
}
Enter a real number between -1 and 1: .32696
Arcsine of 0.326960 = 0.333085
Arccosine of 0.326960 = 1.237711