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# Getting Last Character of String

C# Finding the Path to the Windows Fonts Folder

C# Finding the Desktop Path

C# Getting Current Time

C# Reverse Array