Monday, March 14, 2011

3.4 Switch

  • Switch statement is a multi-way decision that tests whether an expression matches one of a number of constant integer values, and branches accordingly
  • Syntax:










  • case labeled default is executed if none of the cases are satisfied
  • default is optional
  • Example:
 


  • Break statement causes an immediate exit from the switch

No comments:

Post a Comment