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

From Serious Documentation
Jump to: navigation, search
(Created page with "== See Also == *Sail Home *Flow_Control == {{SHIP:Sail:Flow_Control|break}} == <onlyinclude>Branch control to follow one branch of ex...")
 
Line 2: Line 2:
 
*[[SHIP:Sail|Sail Home]]
 
*[[SHIP:Sail|Sail Home]]
 
*[[SHIP:Sail:Flow_Control|Flow_Control]]
 
*[[SHIP:Sail:Flow_Control|Flow_Control]]
 +
*[[SHIP:Sail:Flow_Control:continue]]
  
== {{SHIP:Sail:Flow_Control|break}} ==
+
== {{SHIP:Sail:Flow_Control:break|break}} ==
<onlyinclude>Branch control to follow one branch of execution or another.
+
<onlyinclude>Causes execution to exit from a loop or switch statement branch.
  
 
{| class="wikitable" style="margin: 1em 1em;"  
 
{| class="wikitable" style="margin: 1em 1em;"  
Line 10: Line 11:
 
! scope="col" style="text-align:left" | Description
 
! scope="col" style="text-align:left" | Description
 
|-
 
|-
|{{Flow_Control|break}}||Causes immediate termination out of a loop or switch block.
+
|{{Flow_Control:break|break}}||Causes immediate termination out of a loop or switch block.
 
|}</onlyinclude>
 
|}</onlyinclude>
 
== Example ==
 
== Example ==

Revision as of 14:29, 3 October 2016

See Also

Template:SHIP:Sail:Flow Control:break

Causes execution to exit from a loop or switch statement branch.

Statement Description
Template:Flow Control:break Causes immediate termination out of a loop or switch block.

Example

a = 10; while(a) {

  if(a == 5)
     break;
  printf("%d,", a);

} Prints: 10,9,8,7,6

or

switch(a) {

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

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