< Previous | Contents | Next >

Using the continue Statement to Jump Back to the Top of a

Loop

Just before count is displayed, I included the lines:

//skip the number 5 if (count == 5)

{

continue;

}

The continue statement means jump back to the top of the loop.At the top of the loop, the while expression is tested and the loop is entered again if its true. So when count is equal to 5, the program does not get to the cout << count << endl; statement. Instead, it goes right back to the top of the loop. As a result, 5 is skipped and never displayed.