89
C++ Math acos()
This function computes the inverse cosine of a number in radian.
acos(x) = cos -1x
Syntax
Suppose a number is x. Syntax would be:
Note: If the value passed is an integer type, then it is cast to double.
Parameter
x: The value whose arc cosine is to be calculated. It should be in the range[-1,1].
Return value
Parameter | Return value |
---|---|
-1≤x≤1 | (0,∏) |
x<-1 or x>1 | Not a number |
Example 1
Let’s see the simple example when the value of x is greater than 1.
Output:
Value of cosine is :0.000796274 Inverse of cosine is :nan
In this example, acos() function calculates the inverse cosine of a number when the value of x is greater than 1.
Example 2
Let’s see the simple example when the value of x is equal to zero.
Output:
Value of cosine is :1 Inverse of cosine is :1.5708
In this example, acos() function calculates the inverse cosine of a number when the value of x is equal to zero.
Example 3
Let’s see the simple example when the value x is less than -1.
Output:
Value of cosine is :0.50046 Inverse of cosine is :nan
In this example, acos() function calculates the inverse cosine of a number when the value of x is less than -1.
Next TopicC++ Math Functions