What is the output of the following code snippet?
int n = 5;
for (int i = 0; i < n; i++) {
System.out.print(i + " ");
}
for (int i = 0; i < n; i++) {
System.out.print(i + " ");
}
A. 5 4 3 2 1
B. 0 1 2 3 4
C. 1 2 3 4 5
D. 5 4 3 2 1
Answer: Option B
Related Questions on Flow Control
What is the purpose of the "if" statement in Java?
A. To execute a block of code conditionally
B. To create loops
C. To declare variables
D. To define methods
A. No output
B. Error
C. Hello
D. 5
Join The Discussion