March 19, 2004

I admit this is a low-percentage gag. Pretty much only computer programmers will get it. So for the rest of you, if you're just dying to know, here's a dry lecture on while and do-while:

A number of languages (like C, C++, and Java) have a construct called a while loop. It will execute the loop again and again until a given condition is met:

int count = 0;
while ( count<20 )

The above loop would continue looping until count got to be 20. If you were to replace the first line with "int count = 20;" the whole loop would be skipped cause count is already 20 when it gets there. Now. a do-while loop acts the same way, but it doesn't start with a check.

int count = 20;
} while ( count<20 );

In the above example, the code inside the do-while loop would be executied even though count is already 20. But then execution would continue on past (It would only do the loop once).

So anyway, that's what a while loop and a do-while loop are. In actual usage, I'd say I use while about 20 times as often as do-while.


Casey and Andy and all characters therein are Copyright 2002-2005, Andy Weir. Casey and Andy
Updates on Monday, Wednesday, and Friday.