floating points are approximations. x is not EXACTLY the square root of 2, it's just a very close approximation.

When you multiply x by itself, you're probably getting 1.999999999999999 or something to that effect, which does not equal 2, so that condition returns false.

Always be wary when using != and == to compare floating point numbers. In practice, you should probably never do it.

I just have trouble with this one because I don't know if n is updated within the iteration, or if n = 2 for iteration 1 and n = 3 for iteration 2.

No, n would be 1 for the entire loop, and would only be 2 once the loop completes. You are not incrementing n within the loop body. So the result would be: