Home >>C Math Functions >C math acos() function

C math acos() function

C math acos() function

C math double acos(double x) function is used to return the arc cosine (inverse cosine) of any number x in radians. It takes a single argument x (1 ≥ x ≥ -1) and returns the arc cosine of it in radians. This function is included in <math.h> header file of C language.

Syntax:
double acos(double x)

Parameters

x It is a floating point value in the interval [-1,+1].

Here is an example of acos() function:

#include <stdio.h>
#include <math.h>
#define PI 3.14159265 
int main () 
{ 
double x, ret, val; 
x = 0.75; 
val = 180.0 / PI; 
ret = acos(x) * val; 
printf("The arc cosine of %lf is %lf degrees", x, ret); 
return(0); 
}

Output:
The arc cosine of 0.750000 is 41.409622 degrees
Example-2

#include <stdio.h>
#include <math.h>
#define PI 3.14159265 
int main () 
{ 
double x, ret, val; 
x = 0.555; 
val = 180.0 / PI; 
ret = acos(x) * val; 
printf("The arc cosine of %lf is %lf degrees", x, ret); 
return(0); 
}

Output:
The arc cosine of 0.555000 is 56.289285 degrees

No Sidebar ads