Convert following do-while loop into for loop.

int i = 1;
int d = 5;
do {
    d=d*2;
    System.out.println(d);
    i++ ; } while ( i<=5);

Views 5

Answer:


int i = 1;
int d = 5;
for (i = 1; i <= 5; i++) {
    d=d*2;
    System.out.println(d);
}

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.