Question 6
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int i, j;
for (i = 0, j = 10; i < j; i += 3, j -= 2) {
}
printf("%d %d\n", i, j);
return 0;
}
- A 6 6 Correct
- B 9 4
- C 3 8
- D 6 8
Correct Answer: Option A
The pairs are (0, 10), (3, 8), then (6, 6), where i < j is false. Both updates happen together in each step.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!