79.5k views
0 votes
Int i = 1, mult3 = 3;

while (mult3 < 20)

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

i++;

mult3 *= i;

User Paaacman
by
6.3k points

1 Answer

2 votes

Answer:

3 6 18

Step-by-step explanation:

Code segment:

int i = 1, mult3 = 3;

while (mult3 < 20) {

// We assume the body of the while loop to be enclosed in {}

// Otherwise the code will print 3 in an infinite loop

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

i++;

mult3 *= i;

}

Let us iterate through the while loop:

i=1 , mult3 = 3

i=2 , mult3 = 6

i=3 , mult3 = 18

i=4, mult3 = 72 ( The while loop terminates)

So the code will print out the following result:

3 6 18

User BlakeTNC
by
6.2k points