Jump to content

Loops/Continue: Difference between revisions

no edit summary
No edit summary
Line 6:
Ada has no continue reserved word, nor does it need one. The continue reserved word is only syntactic sugar for operations that can be achieved without it as in the following example.
 
<lang ada>
with Ada.Text_Io; use Ada.Text_Io;
 
Line 20:
end loop;
end Loop_Continue;
</adalang>
=={{header|ALGOL 68}}==
[[ALGOL 68]] has no continue reserved word, nor does it need one. The continue reserved word is only syntactic sugar for operations that can be achieved without it as in the following example:
Line 42:
=={{header|C}}==
{{trans|C++}}
<lang c>for(int i = 1;i <= 10; i++){
printf("%d", i);
if(i % 5 == 0){
Line 49:
}
printf(", ");
}</clang>
 
=={{header|C++}}==
{{trans|Java}}
<lang cpp>for(int i = 1;i <= 10; i++){
cout << i;
if(i % 5 == 0){
Line 60:
}
cout << ", ";
}</cpplang>
 
=={{header|ColdFusion}}==
Line 78:
 
=={{header|D}}==
<lang d>for(int i = 1;i <= 10; i++){
writef(i);
if(i % 5 == 0){
Line 85:
}
writef(", ");
}</dlang>
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
Line 125:
 
=={{header|Java}}==
<lang java>for(int i = 1;i <= 10; i++){
System.out.print(i);
if(i % 5 == 0){
Line 132:
}
System.out.print(", ");
}</javalang>
 
=={{header|MAXScript}}==
Line 166:
 
=={{header|Perl}}==
<lang perl>foreach (1..10) {
print $_;
if ($_ % 5 == 0) {
Line 173:
}
print ', ';
}</perllang>
 
=={{header|PHP}}==
<lang php>for ($i = 1; $i <= 10; $i++) {
echo $i;
if ($i % 5 == 0) {
Line 183:
}
echo ', ';
}</phplang>
 
=={{header|Pop11}}==
Line 199:
 
=={{header|Python}}==
<lang python>for i in xrange(1,11):
if i % 5 == 0:
print i
continue
print i, ",",</pythonlang>
 
=={{header|Ruby}}==
<lang ruby>for i in 1..10 do
print i
if i % 5 == 0 then
Line 213:
end
print ', '
end</rubylang>
 
=={{header|UnixPipes}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.