Computer Science, asked by anshika673245, 5 months ago

helppppppppppppppp :(​

Attachments:

Answers

Answered by Oreki
1

Given program:

public class PI {

   public static void main(String[ ] args) {

       int i = 2, k = 1;

       while (++i < 6) {

           k *= i;

           System.out.println(k);

}  }  }

Explanation:

Initially, i = 2 and k = 1, then,

   Iteration 1:

       ++i => 3, is 3 < 6, Yes,

       k *= 3 or k = 1 * 3, k = 3.

   Iteration 2:

       ++i => 4, is 4 < 6, Yes,

       k *= 4 or k = 3 * 4, k = 12.

   Iteration 3:

       ++i => 5, is 5 < 6, Yes,

       k *= 5 or k = 12 * 5, k = 60.

   Iteration 4:

       ++i => 6, is 6 < 6, No.

Hence, the loop terminates.

Output:

3

12

60

Similar questions