Break and Continue

The break statement is used to exit out of a while loop. If more then one while loop is nested, the break statement breaks out of the innermost loop.

while (condition)

   {

   if (should_exit)

       break        // exit the while loop

   …

   }

 

The continue statement continues again at the top of the loop, just before condition expression is evalu­ated.

while (condition)

   {

   if (skip_rest_loop)

       continue         // continue at the top of the while loop

   …

   }