C# Finding Cosine of an Angle

You can use the Cos() function of the Math class to find the cosine of an angle in C#.

This function takes radians as a parameter and returns you the cosine value.

If you have an angle, you should convert it to radians like this..

  • radian = angle * (pi number /180);

Let's examine the example below..

namespace ConsoleApplicationTest
{
    class Program {

        static void Main(string[] args) {

            double a = 80;
            double radian = a * (Math.PI / 180);
            double cos = Math.Cos(radian);
                       
            Console.WriteLine(cos);
            
            Console.ReadLine();
        }
    }
}

To find the cosine of the angle, we first convert the angle to radians. Then we send it to the function as a parameter. The result returned us as "0.173648..".


C#

You May Interest

C# Finding the Desktop Path

C# Taking Action by MessageBox OK Button

C# Finding the Sine of an Angle

C# Finding the Operating System Username

C# How To Find The Average Of 10 Numbers Using A While Loop