Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Use of break statement in C++

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.

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();

 }



This post first appeared on Programming Explain, please read the originial post: here

Share the post

Use of break statement in C++

×

Subscribe to Programming Explain

Get updates delivered right to your inbox!

Thank you for your subscription

×