KnowledgeBoat Logo
|

Computer Applications

Rewrite the following code using for loop.

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

Java Iterative Stmts

7 Likes

Answer

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

Answered By

6 Likes


Related Questions