✏️ Explanatory Question
int p = 200; while(true) { if(p < 100) break; p = p - 20; } System.out.println(p);
Analysis of the loop:
Initial value of p = 200. The loop keeps subtracting 20 from p until p < 100. The loop executes as follows:
p = 200 - 20 = 180p = 180 - 20 = 160p = 160 - 20 = 140p = 140 - 20 = 120p = 120 - 20 = 100p = 100 - 20 = 80The loop stops when p becomes 80. The output will be:
Output:80
The loop will be executed 6 times.