SHIP:Sail:Flow Control:case

From Serious Documentation
Revision as of 13:39, 3 October 2016 by CarltonHeyer (talk | contribs) (Created page with "== See Also == *Sail Home *switch == {{Flow_Control:case|case}} == <onlyinclude>Branch control that works in conjunction with the swi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

See Also

Template:Flow Control:case

Branch control that works in conjunction with the switch statement.

Statement Description
Template:Flow Control Causes code execution to branch to the matching switch statement expression.

Example

switch(a) {

  case 1:
     printf("1");
     break;
  case 2:
     printf("2");
     break;
  case 3:
     printf("3");
     break;
  case 4:
     printf("4");
     break;
  default;
     break;

} Prints: a = 1 ->1 a = 2 ->2 a = 3 ->3 a = 4 ->4