C acos function calculates the arc cosine

Syntax

C acos function has the following syntax.

  • float acosf(float arg);
  • double acos(double arg);
  • long double acosl(long double arg);

C acos function is from header file math.h.

Description

The return value from the acos() is arc cosine of arg. Parameter of acos() must be in the range -1 to 1.

Example

The following code uses a do while loop to calculate arc cosine for value from 0.1 to 1.


#include <math.h>
#include <stdio.h>
//from  w w  w.j  a v a  2s .  c o  m
int main(void)
{
  double val = -1.0;

  do {
    printf("Arc cosine of %f is %f.\n", val, acos(val));
    val += 0.1;
  } while(val<=1.0);

  return 0;
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h