Loops/Do-while

From Rosetta Code
Revision as of 18:30, 14 April 2008 by rosettacode>Mwn3d (Created page with Java)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Loops/Do-while
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.

Java

<java>int val = 0; do{

  val++;
  System.out.println(val);

}while(val % 6 != 0);</java>