Loops/Do-while: Difference between revisions

PascalABC.NET
(Added MSX Basic and Quite BASIC)
(PascalABC.NET)
 
(7 intermediate revisions by 4 users not shown)
Line 935:
std::cout << val << std::endl;
}while(val % 6 != 0);</syntaxhighlight>
 
=={{header|WrenC3}}==
In this example we use default zero initialization of locals in C3.
<syntaxhighlight lang="easylangc3">int val;
do
{
io::printn(++val);
}
}while (val % 6 != 0);</syntaxhighlight>
 
=={{header|Chapel}}==
Line 1,174 ⟶ 1,183:
 
=={{header|EasyLang}}==
}</syntaxhighlight>
EasyLang does not include an built-in do-while loop, but a repeat-until loop can be used, with the condition inside a '''not''' operator.
<syntaxhighlight lang="easylang">
value = 0
repeat
value += 1
print value
until not (value mod 6 <>= 0)
.
</syntaxhighlight>
Line 2,316 ⟶ 2,324:
inc val
echo val</syntaxhighlight>
 
=={{header|Nu}}==
<syntaxhighlight lang="ecmascriptnu">var v = 0
mut n = 0
while (true) {
$n += 1
print $n
if $n mod if (v%6 == 0) {break}
}
</syntaxhighlight>
 
=={{header|Oberon-2}}==
Line 2,458 ⟶ 2,476:
until i mod 6 = 0
end.</syntaxhighlight>
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="ecmascriptdelphi">var value = 0
begin
var oka := true0;
repeat
va += v + 1;
Print(a);
until a mod 6 = 0;
end.
</syntaxhighlight>
 
 
 
=={{header|Perl}}==
Line 3,272 ⟶ 3,303:
endmodule
</syntaxhighlight>
 
=={{header|Wren}}==
Wren doesn't have a ''do/while'' loop as such but we can simulate it using an infinite loop with a final conditional break.
<syntaxhighlight lang="ecmascript">var v = 0
while (true) {
v = v + 1
System.print(v)
if (v%6 == 0) break
}</syntaxhighlight>
{{out}}
<pre>
</pre>
It can also be simulated ''without'' using a break statement as follows:
<syntaxhighlight lang="ecmascript">var value = 0
var ok = true
while (ok) {
value = value + 1
System.print(value)
ok = value%6 != 0
}</syntaxhighlight>
 
{{out}}
<pre>
Same as before.
</pre>
 
=={{header|V (Vlang)}}==
Line 3,360:
println(n3) // prt 8
}</syntaxhighlight>
 
=={{header|Wren}}==
Wren doesn't have a ''do/while'' loop as such but we can simulate it using an infinite loop with a final conditional break.
<syntaxhighlight lang="wren">var v = 0
while (true) {
v = v + 1
System.print(v)
if (v%6 == 0) break
}</syntaxhighlight>
{{out}}
<pre>
</pre>
It can also be simulated ''without'' using a break statement as follows:
<syntaxhighlight lang="wren">var value = 0
var ok = true
while (ok) {
value = value + 1
System.print(value)
ok = value%6 != 0
}</syntaxhighlight>
 
{{out}}
<pre>
Same as before.
</pre>
 
=={{header|X86 Assembly}}==
246

edits