Square Root Calculator I have now written a simple square root calculator using the division method:



static void Main(string[] args)
{
    double num, sqrt = 0;
    int currentDecimal = 0, decimalAccuracyLevel, intAccuracyLevel = 5;

    do
    {
        Console.Write("Enter your number: ");
    } while (!double.TryParse(Console.ReadLine(), out num));

    do
    {
        Console.Write("Enter the number of decimal points you wish to be accurate to: ");
    } while (!int.TryParse(Console.ReadLine(), out decimalAccuracyLevel) &amp;&amp; decimalAccuracyLevel &gt;= 0);

    while (0 &lt; intAccuracyLevel)
    {
        double currentIncrement = Math.Pow(10, intAccuracyLevel);

        while (Math.Pow(sqrt + currentIncrement, 2) &lt;= num)
        {
            sqrt += currentIncrement;
        }

        intAccuracyLevel--;
    }

    while (currentDecimal &lt;= decimalAccuracyLevel)
    {
        double currentIncrement = (double)1 / Math.Pow(10, currentDecimal);

        while (Math.Pow(sqrt + currentIncrement, 2) &lt;= num)
        {
            sqrt += currentIncrement;
        }

        currentDecimal++;
    }

    Console.WriteLine(sqrt);
}


Is there anything I should do to improve performance or accuracy?
Declare your variables a near as possible to their usage.



Initializing multiple variables on a single line removes readability and can lead in some languages to unexpected results.  



If you divide two numbers and one of the numbers is a double the result is not a integer division result, hence you don't need the cast to double.  



Because you are reinventing the wheel, it would be appropriate to do the Pow() by your code, because otherwise you could simply use Math.Pow(num, 0.5).  



You should name your variables better. The int currentDecimal variable is storing the current calculated decimal points, but it reads that it holds the current Decimal number. You should rename it to currentDecimalPoint or something more meaningful.  



This is a small application, but you should nevertheless extract the reading of the user input and the calculation of the result to separate methods.