Working on Angles

We going to see one of the important note that every begineer will easily forget. Your programming language cannot understand degree, it can only understand Radian. So even if you get input in unit degree, convert that to Radian and proceed your code. Lets study this in detail with some sample codes.

CODE

static void Main(string[] args) {
    //I want to find sin 30 degree, where the answer is 0.5. but if i try running below code i'll get different output
    Console.WriteLine(Math.Sin(30)); // Output : -0.988031624092862

    //This is because system cannot understand degree , we need to convert degree to radian
    Console.WriteLine(Math.Sin(30*Math.PI/180));// Output : 0.5

    //I want to find cos 30 degree, where the answer is 0.866025403784439. but if i try running below code i'll get wrong output
    Console.WriteLine(Math.Cos(30)); // Output : 0.154251449887584
    Console.WriteLine(Math.Cos(30*Math.PI/180)); // Output : 0.866025403784439
}


(Click Here, For more exercises)