![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Math.Acos() Method in C#
The Math.Acos() method in C# returns the angle whose cosine is the specified number. This number is a double value argument.
Syntax
The syntax is as follows −
public static double Acos (double val);
Above, Val is the number representing a cosine, where Val must be greater than or equal to -1, but less than or equal to 1.
Example
Let us now see an example to implement Math.Acos() method −
using System; public class Demo { public static void Main(){ double val1 = -0.0; double val2 = Double.PositiveInfinity; double val3 = Double.NaN; Console.WriteLine("Return value of {0} : {1}", val1, Math.Acos(val1)); Console.WriteLine("Return value of {0} : {1}", val2, Math.Acos(val2)); Console.WriteLine("Return value of {0} : {1}", val2, Math.Acos(val3)); } }
Output
This will produce the following output −
Return value of 0 : 1.5707963267949 Return value of ∞ : NaN Return value of ∞ : NaN
Example
Let us see another example to implement Math.Acos() method −
using System; public class Demo { public static void Main(){ double val1 = -30.0; double val2 = 30.0; double val3 = 0; Console.WriteLine("Return value of {0} : {1}", val1, Math.Acos(val1)); Console.WriteLine("Return value of {0} : {1}", val2, Math.Acos(val2)); Console.WriteLine("Return value of {0} : {1}", val2, Math.Acos(val3)); } }
Output
This will produce the following output −
Return value of -30 : NaN Return value of 30 : NaN Return value of 30 : 1.5707963267949
Advertisements