In this C# tutorial we "calculate square root of any number entered by the user" . For this here we are taking two variables "sq" for square root and "n" for number entered by the user respectively. Also here we are using "Math.Sqrt" method which is used to find square root of a number at runtime. Now, lets get started!!
>using System; class prg { public static void Main(String []args) { double sq,n; Console.WriteLine("Enter any number : "); n=Convert.ToInt32(Console.ReadLine()); //Math.Sqrt method computes a square root value at runtime. sq=Math.Sqrt(n); Console.WriteLine("Square root of " + n + "is" + sq); } }
0 comments:
Post a Comment