C# has a built-in Math
class that provides useful mathematical functions and operations. The Math
class has the Sqrt()
function, which is used to compute the square root of a specified number.
public static double Sqrt (double value);
value
: value
is of the Double
type and represents the input value for which we have to find Sqrt()
. Its range is all double numbers.Double
: Sqrt()
returns a Double
number representing the square root of the value
.NaN
: Sqrt()
returns NaN
type for negative numbers or NaN
input in value
.PositiveInfinity
: Sqrt()
returns PositiveInfinity
for the PositiveInfinity
input in value
.using System;class Educative{static void Main(){Double result = Math.Sqrt(-0.16);System.Console.WriteLine("Sqrt(0.16) = "+ result);Double result1 = Math.Sqrt(0);System.Console.WriteLine("Sqrt(0) = "+ result1);Double result2 = Math.Sqrt(16);System.Console.WriteLine("Sqrt(16) = "+ result2);Double result3 = Math.Sqrt(Double.PositiveInfinity);System.Console.WriteLine("Sqrt(∞) = "+ result3);Double result4 = Math.Sqrt(Double.NegativeInfinity);System.Console.WriteLine("Sqrt(-∞) = "+ result4);}}