Approximating the square root using an iterative method
Do not rely on a fixed number of iterations. Stop when reaching a desired discrepancy (e.g. fabs(x*x - n) &lt; epsilon)
I do not see any reason for not simplifying the calculations into x = (x + n/x)/2.0.
Assure that the input is positive.