158k views
22 votes
7. Rewrite this "for" loop into a while loop:

for (int i = 0; i < 6; i = (i + 2)/2) {
System.out.print(i + " ");
}
+

User Foreever
by
3.8k points

1 Answer

7 votes

Answer:

int i = 0;

while (i<6) {

System.out.print(i + " ");

i = (i+2)/2;

}

Step-by-step explanation:

User DubVader
by
4.2k points