Question 3
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int x = 10;
do {
printf("%d ", x);
x++;
} while (x < 5);
printf("| %d\n", x);
return 0;
}
- A 10 | 11 Correct
- B | 10
- C 10 11 | 12
- D Nothing
Correct Answer: Option A
The body runs once before the condition is checked, printing 10 and making x 11. Then 11 < 5 is false and the loop ends.
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!