break statement is used to break or jump out of the loop.
continue statement is used to skip loop body executes for that iteration.
Let's see the flow diagram of both
Break statement flow diagram
continue statement flow diagram
The break statement
We have already seen the
break statement when we were learning switch statement.
break statement was used to jump out of switch statement.
switch statement is also used to jump out of loops. It is enclosed in a conditional statement and it is executed when the condition is true.
Here is an example of a
break statement which jumps out of loop when count becomes 4.
The continue statement
continue statement is used to jump one iteration of the loop. It skips the execution of code for that iteration when it is executed.
In the example below continue statement runs when count is equal to 4, and skip the code below it without executing.
The label statement
label_name: // Single or Multiple Code // Statements
label name can be used to
continue the block of code.
break label_name; continue label_name;