• admin@embedclogic.com

break and continue statements

break statement

The break statement is used to terminate the nearest closing loop or switch-case statement.After termination of loop, control transfer to the followed statement.


Flow Diagram:

break statement role in function


15In below example, Control will remain inside the loop until positive input is not available.when positive input found control will transfer to the just outside of the immediate loop.

Continue statement

Continue statement used inside the loops. Unlike the break statement when continue found inside the loop then execution of the remaining statments of current iteration will skip as well control transfer to the start of the loop for next iteration.


Flow Diagram


In above example, you can see that count=4 is skipped because when the count equals to 4 then if statement gets true and execute the continue statement which transfers the control to initial of the loop for next iteration without executing the next statement of current execution.