Anonymous user
Loops/For with a specified step: Difference between revisions
m
Fixed lang tags.
Underscore (talk | contribs) (Added Perl 6.) |
m (Fixed lang tags.) |
||
Line 75:
=={{header|C}}==
This prints all odd digits:
<lang c>int i;
for(i = 1; i < 10; i += 2)
printf("%d\n", i);</lang>
</lang>▼
=={{header|C++}}==
This prints all odd digits:
<lang cpp>for (int i = 1; i < 10; i += 2)
std::cout << i << std::endl;</lang>▼
▲ std::cout << i << std::endl;
=={{header|Common Lisp}}==
Line 95 ⟶ 91:
=={{header|D}}==
Print odd numbers up to 9.
<lang d>for (int i = 1; i < 10; i += 2)
std.stdio.writefln("%d\n",i);</lang>▼
▲ std.stdio.writefln("%d\n",i);
=={{header|E}}==
Line 139 ⟶ 133:
=={{header|FALSE}}==
<lang false>2[$9\>][$.", "2+]#"who do we appreciate!"</lang>▼
▲2[$9\>][$.", "2+]#"who do we appreciate!"
=={{header|Forth}}==
<lang forth>: test
9 2 do
i .
2 +loop
." who do we appreciate?" cr ;</lang>
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
<lang fortran>
=={{header|Haskell}}==
Line 163 ⟶ 153:
putStrLn "who do we appreciate?"</lang>
=={{header|J}}==
2 4 6 8 who do we appreciate?</lang>
=={{header|Java}}==
Line 181 ⟶ 170:
=={{header|Lisaac}}==
<lang Lisaac>1.to 9 by 2 do { i : INTEGER;
i.print;
'\n'.print;
};</lang>
=={{header|Logo}}==
<lang logo>for [i 2 8 2] [type :i type "|, |] print [who do we appreciate?]</lang>▼
▲for [i 2 8 2] [type :i type "|, |] print [who do we appreciate?]
=={{header|Modula-3}}==
Line 224 ⟶ 209:
=={{header|M4}}==
<lang M4>define(`for',
`ifelse($#,0,``$0'',
`ifelse(eval($2<=$3),1,
Line 231 ⟶ 215:
for(`x',`1',`5',`3',`x
')</lang>
Output:
Line 316 ⟶ 299:
Prints numbers from 0 to 100 stepping by 5.
<
For i, 0, 100, 5
Disp i
EndFor</
=={{header|UNIX Shell}}==
Line 330 ⟶ 313:
=={{header|Vedit macro language}}==
This prints all odd digits in range 1 to 9:
<lang vedit>for (#1 = 1; #1 < 10; #1 += 2) {
Num_Type(#1)
▲}</lang>
=={{header|Vorpal}}==
<lang vorpal>for(i = 2, i <= 8, i = i + 2){
|