Computer Applications

Rewrite the following program segment using while instead of for loop.

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

Java Iterative Stmts

7 Likes

Answer

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

Answered By

5 Likes


Related Questions