< Previous | Contents | Next >

Using the break Statement to Exit a Loop

This is the exit condition I put in the loop:

//end loop if count is greater than 10 if (count > 10)

{

break;

}

Because count is increased by 1 each time the loop body begins, it will eventually reach 11. When it does, the break statement (which means break out of the loop) is executed and the loop ends.

Using Logical Operators 61