MathF.Cos() Method in C# with Examples



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
Updated on: 2019-11-14T06:10:02+05:30

123 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements