Loops/Downward for: Difference between revisions
Content deleted Content added
Add SmallBASIC |
|||
(11 intermediate revisions by 9 users not shown) | |||
Line 345:
=={{header|ALGOL-M}}==
Sadly, ALGOL-M's FOR statement does not allow a negative value
for STEP, so in order to count down we either have to use a WHILE loop
or move the subtraction into the body of the FOR loop
<syntaxhighlight lang="ALGOL">
begin
Line 351 ⟶ 352:
integer i;
write("First approach :");
i := 10;
while (i >= 0) do
begin
writeon(i);
i := i - 1;
end;
write("Second approach:");
for i := 0 step 1 until 10 do
writeon(10-i);
end
Line 362 ⟶ 368:
{{out}}
<pre>
First approach : 10 9 8 7 6 5 4 3 2 1 0
Second approach: 10 9 8 7 6 5 4 3 2 1 0
</pre>
Line 582 ⟶ 589:
Disp 10-I▶Dec,i
End</syntaxhighlight>
=={{header|Bait}}==
fun main() {
for i := 10; i >= 0; i -= 1 {
println(i)
}
}
=={{header|BASIC}}==
Line 729 ⟶ 745:
next i
end</syntaxhighlight>
==={{header|SmallBASIC}}===
<syntaxhighlight lang="qbasic">
for ii = 10 to 0 step -1
print ii
next
</syntaxhighlight>
==={{header|TI-83 BASIC}}===
Line 1,571 ⟶ 1,594:
=={{header|langur}}==
<syntaxhighlight lang="langur">
for i in 10..0 {
}
</syntaxhighlight>
<syntaxhighlight lang="langur">
for i = 10;
writeln i
▲}</syntaxhighlight>
}
</syntaxhighlight
▲ writeln .i
▲}</syntaxhighlight>
=={{header|Lasso}}==
<syntaxhighlight lang="lasso">loop(-from=10, -to=0, -by=-1) => {^ loop_count + ' ' ^}</syntaxhighlight>
=={{header|LDPL}}==
<syntaxhighlight lang="ldpl">data:
i is number
procedure:
for i from 10 to -1 step -1 do
display i lf
repeat</syntaxhighlight>
=={{header|Lhogho}}==
Line 1,786 ⟶ 1,820:
=={{header|N/t/roff}}==
<syntaxhighlight lang="
.nr a 11 1
.while (\na > 0) \{\
Line 1,830 ⟶ 1,864:
1
0</pre>
=={{header|Nu}}==
<syntaxhighlight lang="nu">
for i in 10..0 {print $i}
</syntaxhighlight>
=={{header|Oberon-2}}==
Line 1,869 ⟶ 1,908:
<syntaxhighlight lang="pascal">for i := 10 downto 0 do
writeln(i);</syntaxhighlight>
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
##
for var i:=10 downto 0 do
Print(i);
</syntaxhighlight>
{{out}}
<pre>
10 9 8 7 6 5 4 3 2 1 0
</pre>
=={{header|Peloton}}==
Line 2,105 ⟶ 2,155:
=={{header|S-BASIC}}==
<syntaxhighlight lang="BASIC">
var i = integer
for i = 10 to 1 step -1
print i;
Line 2,116 ⟶ 2,166:
10 9 8 7 6 5 4 3 2 1
</pre>
=={{header|Scala}}==
Line 2,443 ⟶ 2,492:
=={{header|Wren}}==
<syntaxhighlight lang="
System.print()</syntaxhighlight>
|