On the first iteration:

real is 2.0

imag is 2.0

zreal is 0

zimag is 0

Therefore

zrealans is 0

zimagans is 0

testreal is 2.0

testimag is 2.0

Therefore

sqrt((testreal*testreal) + (testimag*testimag)) is sqrt ((2*2) + (2*2) which is sqrt (8) which is > 2. Thus you always take the first branch, print the message, and return.

Gary

real is 2.0

imag is 2.0

zreal is 0

zimag is 0

Therefore

zrealans is 0

zimagans is 0

testreal is 2.0

testimag is 2.0

Therefore

sqrt((testreal*testreal) + (testimag*testimag)) is sqrt ((2*2) + (2*2) which is sqrt (8) which is > 2. Thus you always take the first branch, print the message, and return.

Gary