Share via


acos

Calculates the arccosine.

doubleacos(doublex**);**

Routine Required Header Optional Headers Compatibility
acos <math.h> <errno.h> ANSI, Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

The acos function returns the arccosine of x in the range 0 to &pi; radians. If x is less than –1 or greater than 1, acos returns an indefinite (same as a quiet NaN). You can modify error handling with the _matherr routine.

Parameter

x

Value between –1 and 1 whose arccosine is to be calculated

Example

/* 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 );
}

Output

Enter a real number between -1 and 1: .32696
Arcsine of 0.326960 = 0.333085
Arccosine of 0.326960 = 1.237711

Floating-Point Support Routines

See Also   asin, atan, cos, _matherr, sin, tan