While Loop Output Prediction
Which of the following code segments produces the output 987654321?
Which of the following code segments produces the output 987654321?
A
int num = 10;
while (num >= 0) {
System.out.print(num);
num–;
}
B
int num = 10;
while (num > 1) {
num–;
System.out.print(num);
}
C
int num = 0;
while (num <= 9) {
System.out.print(10 - num);
num++;
}
D
int num = 10;
while (num >= 1) {
num–;
System.out.print(num);
}
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE