Page 66 - 6437
P. 66
p
3 s rime
p
9 s rime
p
7 s rime
Loop Control Statements
Loop control statements change execution from its normal sequence. When execution
leaves a scope, all automatic objects that were created in that scope are destroyed.
C supports the following control statements.
Control Statement Description
break statement Terminates the loop or switch statement and transfers
execution to the statement immediately following the loop or
switch.
continue statement Causes the loop to skip the remainder of its body and
immediately retest its condition prior to reiterating.
goto statement Transfers control to the labeled statement.
break Statement
The break statement in C programming has the following two usages:
When a break statement is encountered inside a loop, the loop is
immediately terminated and the program control resumes at the next statement following the loop.
It can be used to terminate a case in the switch statement (covered in the
next chapter).
If you are using nested loops, the break statement will stop the execution of the innermost
loop and start executing the next line of code after the block.
Syntax
The syntax for a break statement in C is as follows:
break;
Flow Diagram
68