break statement in C++

The break statement is used to terminate loops or to exit from a switch. It can be used within a for, a >code>while, a do-while or a switch statement.

The break statement is written simply as:

break;

without any embedded expressions or statements.

The break is a keyword in the C++ program and the semicolon must be inserted after the break statement.

We have already seen the use of break statement within the example of switch statement (Click here). The break statement causes a transfer of control out of the entire switch statement, to the first statement following the switch statement.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *