Loops/Downward for: Difference between revisions
< Loops
Content added Content deleted
(→Python) |
m (category) |
||
Line 1: | Line 1: | ||
{{task}} |
{{task}}[[Category:Iteration]] |
||
Write a for loop which writes a countdown from 10 to 0. |
Write a for loop which writes a countdown from 10 to 0. |
||
Revision as of 19:52, 18 April 2008
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
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.
C++
<cpp> for(int i = 10; i >= 0; --i)
std::cout << i << "\n";
</cpp>
Pascal
<pascal> for i := 10 downto 0 do
writeln(i);
</pascal>
Python
<python> for i in xrange(10, -1, -1):
print i
</python>