Difference between revisions of "SHIP:Sail:Flow Control:default"

From Serious Documentation
Jump to: navigation, search
Line 4: Line 4:
 
*[[SHIP:Sail:Flow_Control:switch|switch]]
 
*[[SHIP:Sail:Flow_Control:switch|switch]]
  
== [[Flow_Control:default|default]] ==
+
== [[SHIP:Sail:Flow_Control|default]] ==
 
<onlyinclude>Branch control that works in conjunction with the switch statement.
 
<onlyinclude>Branch control that works in conjunction with the switch statement.
  
Line 11: Line 11:
 
! scope="col" style="text-align:left" | Description
 
! scope="col" style="text-align:left" | Description
 
|-
 
|-
|[[Flow_Control:default|default]]||Causes code execution to branch to it if no matching case statement is found.
+
|[[SHIP:Sail:Flow_Control|default]]||Causes code execution to branch to it if no matching case statement is found.
 
|}</onlyinclude>
 
|}</onlyinclude>
 
== Example ==
 
== Example ==

Revision as of 11:57, 10 October 2016

See Also

default

Branch control that works in conjunction with the switch statement.

Statement Description
default Causes code execution to branch to it if no matching case statement is found.

Example

switch(a)
{
   case 1:
      printf("1");
      break;
   case 2:
      printf("2");
      break;
   case 3:
      printf("3");
      break;
   case 4:
      printf("4");
      break;
   default;
      print("default");
      break;
}

Prints: a = 1 ->1 a = 2 ->2 a = 10 ->default a = 100 ->default