The MathF.Cos() method in C# returns the cosine of a given float value argument.
Syntax
Following is the syntax −
public static float Cos (float val);
Above, Val is the floating-point value.
Example
Let us now see an example to implement the MathF.Cos() method −
using System;
class Demo {
public static void Main(){
float val1 = 70f;
float res = (val1 * (MathF.PI)) / 180;
Console.WriteLine(MathF.Cos(res));
}
}Output
This will produce the following output −
0.34202
Example
Let us now see another example to implement the MathF.Cos() method −
using System;
class Demo {
public static void Main(){
float val1 = 90f;
float res = (val1 * (MathF.PI)) / 180;
Console.WriteLine(MathF.Cos(res));
}
}Output
This will produce the following output −
-4.371139E-08