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

From Serious Documentation
Jump to: navigation, search
(Created page with "== See Also == *Sail Home *Flow Control *do == {{SHIP:Sail:Flow_Control:while|while}} == <onlyinclude>L...")
 
Line 4: Line 4:
 
*[[SHIP:Sail:Flow_Control:do|do]]
 
*[[SHIP:Sail:Flow_Control:do|do]]
  
== {{SHIP:Sail:Flow_Control:while|while}} ==
+
== [[SHIP:Sail:Flow_Control:while|while]] ==
 
<onlyinclude>Loop control construct that evaluates the condition of the loop before executing it.
 
<onlyinclude>Loop control construct that evaluates the condition of the loop before executing it.
  
Line 11: Line 11:
 
! scope="col" style="text-align:left" | Description
 
! scope="col" style="text-align:left" | Description
 
|-
 
|-
|{{Flow_Control:while|while}}||Takes an expression and starts executing in a loop until the control evaluates {{Reserved|false}}.
+
|[[Flow_Control:while|while]]||Takes an expression and starts executing in a loop until the control evaluates {{Reserved|false}}.
 
|}</onlyinclude>
 
|}</onlyinclude>
 
== Example ==
 
== Example ==
<code>
+
<source lang="c">
 
a = 10;
 
a = 10;
 
while(a)
 
while(a)
Line 20: Line 20:
 
   printf("%d,", a);
 
   printf("%d,", a);
 
};
 
};
</code>
+
</source>
 
Prints:
 
Prints:
 
10,9,8,7,6,5,4,3,2,1,
 
10,9,8,7,6,5,4,3,2,1,
 +
 +
[[Category:Flow Control Statements]]

Revision as of 11:40, 4 October 2016

See Also

while

Loop control construct that evaluates the condition of the loop before executing it.

Statement Description
while Takes an expression and starts executing in a loop until the control evaluates false.

Example

a = 10;
while(a)
{
   printf("%d,", a);
};

Prints: 10,9,8,7,6,5,4,3,2,1,