Question 7
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int a = 1, b = a + 1, c = a + b;
printf("%d %d %d\n", a, b, c);
return 0;
}
- A 1 2 3 Correct
- B 1 1 2
- C 1 garbage garbage
- D Compilation error
Correct Answer: Option A
Each declarator's scope starts right after it, and the initialisations happen in order, so b can use a and c can use both.
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!