Computer Applications

Convert the following for loop segment to an exit-controlled loop.

for(k = 10;k >= -1;k--) 
System.out.println(k*2); 
System.out.println(k*4); 

Java Iterative Stmts

5 Likes

Answer

k = 10;
do {
    System.out.println(k * 2);
    k--;
} while (k >= -1);
System.out.println(k * 4);

Answered By

4 Likes


Related Questions