Next: Exercises Up: Looping and Iteration Previous: The do-while statement

break and continue

C provides two commands to control how we loop:

Consider the following example where we read in integer values and process them according to the following conditions. If the value we have read is negative, we wish to print an error message and abandon the loop. If the value read is great than 100, we wish to ignore it and continue to the next value in the data. If the value is zero, we wish to terminate the loop.


Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994