This discussion is archived
3 Replies Latest reply: Sep 27, 2013 10:55 AM by 939520 RSS

NEW TO JAVA..............................

3550a9ec-ae86-4f70-bc73-70b54961b68f Newbie
Currently Being Moderated

For each part below show a for loop that advances the loop index variable (call it i in each case) as shown. For example the loop body can just print the value of i.

  1. From 1 to 10 (inclusive)
  2. From 0 to 10 (inclusive) by steps of two. For example: 0, 2, 4, etc.
  3. From 1 to 1024 (inclusive) doubling each time. For example: 1, 2, 4, 8, 16, etc.
  4. From 10 down to 1 (inclusive).
  5. From 1.0 down to the smallest number still greater than 0.1, cutting the value in half each time. For example: 1.0, 0.5, 0.25, 0.125.