Sunday, August 16, 2009

break and continue

The execution of the loop body can be terminated with break and continue.

break terminates the execution of the loop immediately and the control passes to the next statement following the loop.

continue starts a new round in the loop (jumps to the closing brace of the loop body)

The statements effect only the innermost loop they are executed in.

The flow of the events in different loops:

Fig: The while loop

Fig: The do-while loop

Fig: The for loop

Previous post

Next post

No comments:

Post a Comment