While Loop Output Prediction
Which of the following code segments produces the output 987654321?
A
int num = 10;
while (num > 1) {
num–;
System.out.print(num);
}
B
int num = 0;
while (num <= 9) {
System.out.print(10 - num);
num++;
}
C
int num = 10;
while (num >= 1) {
num–;
System.out.print(num);
}
D
int num = 10;
while (num >= 0) {
System.out.print(num);
num–;
}
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | hitrishabhatia | 1 | 4 | 0m 00s | 70 |
| #2 | meromaroseif | 1 | 1 | 0m 49s | 51 |
| #3 | busemagngr | 1 | 2 | 1m 03s | 27 |
Items per page:
10
1 – 3 of 3
