The break and continue statements

The break and continue statements

It is often necessary to handle exception conditions within loops. The statements break and continue are used for this.

The break command terminates the execution of the innermost enclosing loop, causing execution to resume after the nearest done statement.

To exit from n levels, use the command:

   break n

This will cause execution to resume after the done n levels up.

The continue command causes execution to resume at the while, until or for statement which begins the loop containing the continue command.

You can also specify an argument n|FR to continue which will cause execution to continue at the n|FRth enclosing loop up.


[Home] [Search] [Index] This site maintained by unixhelp@math.rutgers.edu
This page was last updated on September 05, 2006 at 10:30 am and is maintained by webmaster@math.rutgers.edu.
For questions regarding courses and/or special permission, please contact mclausen@math.rutgers.edu.
For questions or comments about this site, please contact help@math.rutgers.edu.
© 2012 Rutgers, The State University of New Jersey. All rights reserved.