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

From Serious Documentation
Jump to: navigation, search
(Example)
 
Line 16: Line 16:
 
<source lang="c">
 
<source lang="c">
 
a = 10;
 
a = 10;
while(a)
+
while(a--)
 
{
 
{
 
   printf("%d,", a);
 
   printf("%d,", a);

Latest revision as of 10:08, 6 December 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,