Why this do-while loop doesn't work as I expected?

Printable View