The break statement, Loop Control Statement in C, Assignment Help

Assignment Help: >> Loop Control Statement >> The break statement, Loop Control Statement in C,

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

 

1131_break_statement_1.png

 

1327_break_statement_3.png

for(initialize clause; conditional expression; increment/decrement clause)

{             

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;

                                }

}

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd