The break Statement

The break statement terminates the smallest enclosing do, for, switch, or while statement in which it appears. It passes control to the statement following the terminated statement.

This statement is often used to exit from a loop or switch statement (see below). The following example illustrates break:

while( c != 'Q' )

{

/* Some C statements here */

if( number_of_characters > 80 )

break; /* Break out of while loop */

/* More C statements here */

}

/* Execution continues here after break statement */