C# - Trigonometry Angles in Degrees using Math Class

Here, we are going to demonstrate the trigonometry angles in degrees using Math class in C#. By Nidhi Last updated : April 15, 2023

Trigonometry Angles in Degrees

Here we will get the values of trigonometry angles for the specified degrees using Math class.

C# program to demonstrate the trigonometry angles in degrees using Math class

The source code to demonstrate the trigonometry angles in degrees is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//C# program to demonstrate the Trigonometry Angles 
//in degrees using Math class

using System;

class Demo
{
    static void Main(string[] args)
    {
        double sin60;
        double cos60;
        double tan60;

        sin60 = Math.Sin(60 * Math.PI / 180);
        cos60 = Math.Cos(60 * Math.PI / 180);
        tan60 = Math.Tan(60 * Math.PI / 180);

        Console.WriteLine("Sin (60)     = "+ sin60);
        Console.WriteLine("Cos (60)     = "+ cos60);
        Console.WriteLine("Tan (60)     = "+ tan60);
    }
}

Output

Sin (60)     = 0.866025403784439
Cos (60)     = 0.5
Tan (60)     = 1.73205080756888
Press any key to continue . . .

Explanation

Here, we created a Demo class that contains the Main() method. In the Main() method, we created three variables of double type.

sin60 = Math.Sin(60 * Math.PI / 180);
cos60 = Math.Cos(60 * Math.PI / 180);
tan60 = Math.Tan(60 * Math.PI / 180);

In the above code we calculated the trigonometry angles based on specified degrees using predefined method of Math class, and then print the result on the console screen.

C# Basic Programs »


Related Programs



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.