@VenomousNinja: To compute a function on computers, code is not always written in the same way a man performs the same computation. At times the methods which are easy for humans may be time-consuming or even infeasible to perform on computers. The usual way of computing most of the mathematical functions on computers is to use numerical methods.
For the square root function specifically, after finding out the greatest number less than or equal to the square root of the given number, the Newton-Raphson method can be used to find out a precise value.
Suppose that you want to find out the square root of 101.
=> x = sqrt(101)
=> x^2 = 101
There are two steps in finding out the root:
1. Use a simple for loop to find out the integer nearest to the actual answer.
Call it X0. And this X0 = 10 for our case obviously.
2. Apply the Newton-Raphson method in the following way there after to
get a precise answer:
x^2 = 101
=> x^2 - 101 = 0
=> f(x) = x^2 - 101
=> f'(x) = 2x : Derivative of (x^2 - 101) w.r.t x
The Newton Raphson method says: Xi+1 = Xi - [ f(Xi)/f'(Xi) ]
In the first step we found out that X0 = 10
Now, X1 = X0 - [ f(X0)/f'(X0) ]
=> X1 = 10 - [ -1 / 20 ]
=> X1 = 10.05
Proceed similarly iteratively till you get a satisfactorily precise answer.
Please see
http://www.shodor.org/unchem/math/newton/index.html
for a more detailed explanation of the Newton Raphson method and
http://mathworld.wolfram.com/NewtonsMethod.html for more mastery on the same.