Loops/For with a specified step: Difference between revisions

Add XPL0 example
m (→‎{{header|REXX}}: indented DO loop, change to use '''output''' template. -- ~~~~)
(Add XPL0 example)
Line 841:
i.print()
}</lang>
 
=={{header|XPL0}}==
The 'for' loop always steps by 1 (or -1 for 'downto'). However there is
no restriction on how the control variable can be used or manipulated,
thus a step by 2 can be implemented like this:
 
<lang XPL0>include c:\cxpl\codes;
int I;
[for I:= 2 to 8 do
[IntOut(0, I); Text(0, ", ");
I:= I+1;
];
Text(0, "who do we appreciate?");
]</lang>
 
Output:
<pre>
2, 4, 6, 8, who do we appreciate?
</pre>
 
=={{header|ZX Spectrum Basic}}==
772

edits