Loops/Continue: Difference between revisions

Content added Content deleted
No edit summary
Line 6: 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.
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.


<ada>
<lang ada>
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Text_Io; use Ada.Text_Io;


Line 20: Line 20:
end loop;
end loop;
end Loop_Continue;
end Loop_Continue;
</ada>
</lang>
=={{header|ALGOL 68}}==
=={{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:
[[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: Line 42:
=={{header|C}}==
=={{header|C}}==
{{trans|C++}}
{{trans|C++}}
<c>for(int i = 1;i <= 10; i++){
<lang c>for(int i = 1;i <= 10; i++){
printf("%d", i);
printf("%d", i);
if(i % 5 == 0){
if(i % 5 == 0){
Line 49: Line 49:
}
}
printf(", ");
printf(", ");
}</c>
}</lang>


=={{header|C++}}==
=={{header|C++}}==
{{trans|Java}}
{{trans|Java}}
<cpp>for(int i = 1;i <= 10; i++){
<lang cpp>for(int i = 1;i <= 10; i++){
cout << i;
cout << i;
if(i % 5 == 0){
if(i % 5 == 0){
Line 60: Line 60:
}
}
cout << ", ";
cout << ", ";
}</cpp>
}</lang>


=={{header|ColdFusion}}==
=={{header|ColdFusion}}==
Line 78: Line 78:


=={{header|D}}==
=={{header|D}}==
<d>for(int i = 1;i <= 10; i++){
<lang d>for(int i = 1;i <= 10; i++){
writef(i);
writef(i);
if(i % 5 == 0){
if(i % 5 == 0){
Line 85: Line 85:
}
}
writef(", ");
writef(", ");
}</d>
}</lang>
=={{header|Fortran}}==
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
{{works with|Fortran|90 and later}}
Line 125: Line 125:


=={{header|Java}}==
=={{header|Java}}==
<java>for(int i = 1;i <= 10; i++){
<lang java>for(int i = 1;i <= 10; i++){
System.out.print(i);
System.out.print(i);
if(i % 5 == 0){
if(i % 5 == 0){
Line 132: Line 132:
}
}
System.out.print(", ");
System.out.print(", ");
}</java>
}</lang>


=={{header|MAXScript}}==
=={{header|MAXScript}}==
Line 166: Line 166:


=={{header|Perl}}==
=={{header|Perl}}==
<perl>foreach (1..10) {
<lang perl>foreach (1..10) {
print $_;
print $_;
if ($_ % 5 == 0) {
if ($_ % 5 == 0) {
Line 173: Line 173:
}
}
print ', ';
print ', ';
}</perl>
}</lang>


=={{header|PHP}}==
=={{header|PHP}}==
<php>for ($i = 1; $i <= 10; $i++) {
<lang php>for ($i = 1; $i <= 10; $i++) {
echo $i;
echo $i;
if ($i % 5 == 0) {
if ($i % 5 == 0) {
Line 183: Line 183:
}
}
echo ', ';
echo ', ';
}</php>
}</lang>


=={{header|Pop11}}==
=={{header|Pop11}}==
Line 199: Line 199:


=={{header|Python}}==
=={{header|Python}}==
<python>for i in xrange(1,11):
<lang python>for i in xrange(1,11):
if i % 5 == 0:
if i % 5 == 0:
print i
print i
continue
continue
print i, ",",</python>
print i, ",",</lang>


=={{header|Ruby}}==
=={{header|Ruby}}==
<ruby>for i in 1..10 do
<lang ruby>for i in 1..10 do
print i
print i
if i % 5 == 0 then
if i % 5 == 0 then
Line 213: Line 213:
end
end
print ', '
print ', '
end</ruby>
end</lang>


=={{header|UnixPipes}}==
=={{header|UnixPipes}}==