The acos() is an inbuilt function in C++ STL which returns the inverse cosine of a number (argument) in radians. The value which is returned by the acos() function always lies between – to +
Parameters :This function accepts one mandatory parameter x which specifies the value whose inverse cosine should be computed. It must lie between -1 and +1, else a domain-error is thrown. The parameter can be of double, float or long double datatype.
Return :The function returns a numeric value between – and +. It is the counterclockwise angle which is measured in radian.
acos(1.0) = 0 radians acos(1.0) = 0 degrees
acos(-1) = 3.14159 radians acos(-1) = 180 degrees
Errors and Exceptions:
- The function returns no matching function for call to error when a string or character is passed as an argument.
- The function returns nan when a out of range number is passed as an argument.
Below programs illustrate the errors and exceptions of the above method:
prog.cpp:10:17: error: no matching function for call to 'acos(std::__cxx11::string&)' result = acos(x);
acos(3.7) = nan radians acos(3.7) = nan degrees
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- valarray acos() function in C++
- acos() function for complex number in C++
- Difference between user defined function and library function in C/C++
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- How to call function within function in C or C++
- Difference between Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- fma() function in C++
- log() function in C++
- exp() function C++
- div() function in C++
- fegetenv() function in C/C++
- wctrans() function in C/C++
- wmemcpy() function in C/C++
- fegetexceptflag() function in C/C++
- nearbyint() function in C++
- isfinite() function in C++
- wcsncmp() function in C/C++
- wcsrtombs() function in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.