Use the break statement to terminate a loop, switch, or label statement.
Terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated loop.
Syntax
break [label]
Parameter
label | Identifier associated with the label of the statement. |
Description
The break statement includes an optional label that allows the program to break out of a labeled statement. The statements in a labeled statement can be of any type.
Examples
Example 1. The following function has a break statement that terminates the while loop when e is 3, and then returns the value 3 * x.