C++ provides the break Statement to implement middle-exiting control logic. The "break statement" is used to exist from the loop (do, for, while) structure and from the switch structure. It causes immediate exit from the body of loop, in switch structure, it is normally used at the end of statements to terminate the processing of a particular (or each) case. If all "break" statement are omitted from the switch structure, then statements of all remaining cases after the matched case are also executed.
Related Articles
Syntax of break statement
The general syntax of break statement used in C++ do , for, while or switch statements is as follows:statement(s);
break;
Example of break statement
The following example of C++ program illustrates the break statement:#include
#include
main ()
{
char ch;
clrscr();
cout
cin>>ch;
if (ch == 'Q')
break;
getch();
}