What is Math.cos() in C#?
C# has a built-in Math class that provides useful mathematical functions and operations. The Math class has the Cos() function, which is used to compute the cosine of a specified angle.
Syntax
public static double Cos (double value);
Parameters
value:valueis of theDoubletype and represents the input angle for which we have to findCos(). Its range is all real numbers.valueis measured in radians.
Return value
Double:Cos()returns the cosine of a number; its type isDouble. It is true only for all real numbers invalue.NaN:Cos()returnsNaNtype for invalidvalue, i.e., NaN, infinity, or negative infinity.
Degrees can be converted into radians by multiplying degrees by Math.PI/180.
Example
using System;class Educative{static void Main(){double result = Math.Cos(0);System.Console.WriteLine("Cos(0) = "+ result);double result1 = Math.Cos(1);System.Console.WriteLine("Cos(1) = "+ result1);double result2 = Math.Cos(-1);System.Console.WriteLine("Cos(-1) = "+ result2);double result3 = Math.Cos(Double.PositiveInfinity);System.Console.WriteLine("Cos(∞) = "+ result3);double result4 = Math.Cos(400);System.Console.WriteLine("Cos(400) = "+ result4);}}