To find the cosine of a number in C#, you can use the Math.Cos()
function. This function takes an argument in radians and returns the cosine of that angle.
Here's an example of how to use the Math.Cos()
function to find the cosine of 45 degrees:
main.cs169 chars5 lines
In this example, we first convert the angle from degrees to radians using the formula radians = degrees * PI / 180.0
. Then, we pass the radians value to the Math.Cos()
function to find the cosine. Finally, we print out the result using Console.WriteLine()
. The output of this program will be:
main.cs46 chars2 lines
gistlibby LogSnag