11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5: Controlling Program Flow 75The value of expression must be an integer (int, long, or char). The casevalues c1, c2, and c3 must be constants. When the switch statement isencountered, the expression is evaluated and compared to the various caseconstants. Control branches to the case that matches. If none of the casesmatch, control passes to the default clause.Consider the following example code snippet:int choice;cout > choice;switch(choice){case 1:// do “1” processingbreak;case 2:// do “2” processingbreak;case 3:// do “3” processingbreak;}default:cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!