The break statement
We have already seen the use of 'break' in the switch-case statement. This statement can also be used within while, do-while or for loops. An early exit from a loop can be accomplished by using the break statement. The break forces abnormal termination of the loop. When the break statement is encountered inside a loop, the loop is immediately terminated and the program continues with the statement just following the loop. When the loops are nested, the break would only exit from the loop containing it that is the break exits only one loop. A break statement is usually associated with an if statement.
![317_break_statement.png](https://www.expertsmind.com/../CMSImages/317_break_statement.png)
![1131_break_statement_1.png](https://www.expertsmind.com/../CMSImages/1131_break_statement_1.png)
![1327_break_statement_3.png](https://www.expertsmind.com/../CMSImages/1327_break_statement_3.png)
for(initialize clause; conditional expression; increment/decrement clause)
{
![2359_break_statement_4.png](https://www.expertsmind.com/CMSImages/2359_break_statement_4.png)
Example:
void main ( )
{
int n = 1;
while (n < 10)
{
if (n == 3)
{
break;
}
printf ("Number = %d \n", n);
n = n + 1;
}
}