Break and continue statements are two of the most commonly used control flow statements in programming. They both affect the way a loop works, but they do it in different ways. In this article we will discuss the difference between these two statements and how to use them effectively in your code.
About Difference Between Break And Continue Statement
Statement | Difference |
---|---|
Break | Terminates the loop and transfers execution to the statement immediately following the loop. |
Continue | Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. |
Break | Exits from the loop completely. |
Continue | Takes control back to the beginning of the loop for the next iteration. |
Break | Cancels the entire loop. |
Continue | Skips the current iteration. |
Break | Can be used with an optional label to refer to a specific enclosing loop. |
— by
Leave a Reply