A while loop is one of the simplest loop forms. It starts with a condition. The condition evaluates to either true or false. If the condition evaluates to true, the loop goes again. Otherwise, it will stop. For example:
1 2 3 4 5 6
int Counter( 0 );
while( Counter <= 10 )
{
// Do something useful...
++Counter;
}
In this code, before while starts another cycle, it tests the condition. If Counter is less than or equal to 10, it will perform another cycle. If not, the loop will stop. The condition is tested before every cycle. If the condition is false, the body of the loop is never entered.