C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Math acos()This function computes the inverse cosine of a number in radian.
acos(x) = cos -1x
SyntaxSuppose a number is x. Syntax would be: float acos(float x); double acos(double x); long double acos(long double x); double acos(integral x); Note: If the value passed is an integer type, then it is cast to double.Parameterx: The value whose arc cosine is to be calculated. It should be in the range[-1,1]. Return value
Example 1Let's see the simple example when the value of x is greater than 1. #include 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 2Let's see the simple example when the value of x is equal to zero. #include 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 3Let's see the simple example when the value x is less than -1. #include 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
|