Question 5
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int x = (1, 2, 3);
int y;
y = 4, 5;
printf("%d %d\n", x, y);
return 0;
}
- A 3 4 Correct
- B 1 5
- C 3 5
- D 1 4
Correct Answer: Option A
With brackets, the comma operator yields its last operand: x = 3. Without them, = binds tighter than ,, so y = 4, 5 is (y = 4), 5.
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!