Loops/Downward for: Difference between revisions
< Loops
Content added Content deleted
(Ada) |
|||
Line 2: | Line 2: | ||
Write a for loop which writes a countdown from 10 to 0. |
Write a for loop which writes a countdown from 10 to 0. |
||
=={{header|Ada}}== |
|||
<ada> |
|||
for I in reverse 0..10 loop |
|||
Put_Line(Integer'Image(I)); |
|||
end loop; |
|||
</ada> |
|||
=={{header|C++}}== |
=={{header|C++}}== |
||
<cpp> |
<cpp> |
Revision as of 22:29, 18 April 2008
Loops/Downward for
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Write a for loop which writes a countdown from 10 to 0.
Ada
<ada> for I in reverse 0..10 loop
Put_Line(Integer'Image(I));
end loop; </ada>
C++
<cpp> for(int i = 10; i >= 0; --i)
std::cout << i << "\n";
</cpp>
MAXScript
for i in 10 to 0 by -1 do print i
Pascal
<pascal> for i := 10 downto 0 do
writeln(i);
</pascal>
Python
<python> for i in xrange(10, -1, -1):
print i
</python>