Find Square Root

Write a program to Find Square Root of given number

For example:

Input:
4

Output
2

Solution:

using System;

namespace SquareRoot
{
    class SquareRoot
    {
        public static void Main()
        {
            Console.WriteLine("Enter a number:");
            var rows = Convert.ToInt32(Console.ReadLine());

            var root = 0.0f;
            var square = root;
            while (square < rows)
            {
                root++;
                square = root * root;
            }
            
            Console.WriteLine(root);
            Console.ReadLine();
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *