C# program to take a number as input and calculate the square root of given number


Following program shows you how to take a number as input and calculate the square root of given number.
In this program we get input from user and calculate square root using Math.sqrt() method

using System;

public class squareroot
    {
        public static void Main(String[] args
        )
        {
          Console.WriteLine("Enter a Number : ");
          double input = Convert.ToDouble(Console.ReadLine());
          double result = Math.Sqrt(input);
          Console.WriteLine("Input: " + input);
          Console.WriteLine("Square root of " + input + " is: " + result);
              
        }
    }

Output:

Enter a Number : 
 16
Input: 16
Square root of 16 is: 4