C Standard Library

C <math.h> - acos() Function



The C <math.h> acos() function returns arc cosine of a value. The returned value will be in the range 0 through 𝜋.

Note: acos() is the inverse of cos().

Syntax

double acos (double x);
float acosf (float x);
long double acosl (long double x);

Parameters

x Specify the value in range [-1, 1].

Return Value

Returns the arc cosine of the value.
If the x is not in the range of [-1, 1], domain error occurs.

Example:

In the example below, acos() function is used to find out the arc cosine of a given value.

#include <stdio.h>
#include <math.h>
 
int main (){
  printf("%lf\n",acos(0.25));
  printf("%lf\n",acos(0.5));
  printf("%lf\n",acos(1));
  return 0;
}

The output of the above code will be:

1.318116
1.047198
0.000000

❮ C <math.h> Library