- Trending Categories
- 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.Cos() Method in C#
The Math.Cos() method in C# is used to return the cosine of the angle set as a parameter.
Syntax
Following is the syntax −
public static double Cos (double val);
Above, Val is the angle.
Example
Let us now see an example to implement Math.Cos() method −
using System; public class Demo { public static void Main(){ double val1 = 30.0; Console.WriteLine(Math.Cos( (val1 * (Math.PI)) / 180 )); } }
Output
This will produce the following output −
0.866025403784439
Example
Let us see another example to implement Math.Cos() method −
using System; public class Demo { public static void Main(){ double val1 = 0.0; double val2 = 90.0; Console.WriteLine(Math.Cos( (val1 * (Math.PI)) / 180 )); Console.WriteLine(Math.Cos( (val2 * (Math.PI)) / 180 )); } }
Output
This will produce the following output −
1 6.12303176911189E-17
Advertisements