QUESTION IMAGE
Question
what will the following program print when run?
for (var j = 0; j < 2; j++) {
for (var i = 6; i > 4; i--)(
println (i);
}
}
4
5
4
5
6
5
4
6
5
4
0
2
6
4
6
5
6
5
Step1: Analyze the outer loop
The outer loop for (var j = 0; j < 2; j++) runs 2 times.
Step2: Analyze the inner loop
The inner loop for (var i = 6; i > 4; i--) runs when i = 6 and i = 5 (since \(i>4\)). For each iteration of the outer loop, the inner loop prints 6 and 5.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
6 5 6 5