Difference between revisions of "For"

From Mesham
Jump to navigationJump to search
(Created page with '== Syntax == for i from a to b forbody; == Semantics == The for loop can be thought of as syntactic sugar for a while loop, incrementing the variable after each pass and will …')
 
Line 16: Line 16:
  
 
This code example will loop from 0 to 9 (10 iterations) and display the value of ''i'' on each pass.
 
This code example will loop from 0 to 9 (10 iterations) and display the value of ''i'' on each pass.
 +
 +
[[Category:sequential]]

Revision as of 15:55, 31 December 2009

Syntax

for i from a to b forbody;

Semantics

The for loop can be thought of as syntactic sugar for a while loop, incrementing the variable after each pass and will loop from a to b

Example

var i;
for i from 0 to 9
{
   print[i];
};

This code example will loop from 0 to 9 (10 iterations) and display the value of i on each pass.