Loops/Do-while: Difference between revisions
< Loops
Content added Content deleted
(Created page with Java) |
(Added BASIC example) |
||
Line 1: | Line 1: | ||
{{task}}[[Category:Iteration]]Start with a value at 0. Loop while value mod 6 is not equal to 0. Each time through the loop, add 1 to the value then print it. The loop must execute at least once. |
{{task}}[[Category:Iteration]]Start with a value at 0. Loop while value mod 6 is not equal to 0. Each time through the loop, add 1 to the value then print it. The loop must execute at least once. |
||
=={{header|BASIC}}== |
|||
{{works with|QuickBasic|4.5}} |
|||
<qbasic>a = 0 |
|||
do |
|||
a = a + 1 |
|||
print a |
|||
loop while a mod 6 <> 0</qbasic> |
|||
=={{header|Java}}== |
=={{header|Java}}== |
Revision as of 18:38, 14 April 2008
Loops/Do-while
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.
Start with a value at 0. Loop while value mod 6 is not equal to 0. Each time through the loop, add 1 to the value then print it. The loop must execute at least once.
BASIC
<qbasic>a = 0 do
a = a + 1 print a
loop while a mod 6 <> 0</qbasic>
Java
<java>int val = 0; do{
val++; System.out.println(val);
}while(val % 6 != 0);</java>