ProgrammingHardGATE CS · Campus placements
What does printf("%d", (4, 5) * 2) print?
- A. 10
- B. 8
- C. 9
- D. 5
Correct answer: A. 10
In a comma expression the left operand is evaluated and discarded, so (4, 5) yields 5. Multiplying by 2 gives 10.
More C Programming questions
- int x = 0, y = 1; What does printf("%d", !x == y) print?
- printf("%d %d", 1 < 2 < 3, 3 > 2 > 1); What is printed?
- What does printf("%d", -5 % 3) print?
- double x = 7 / 2 2.0; printf("%g", x); What is printed?
- unsigned char c = 0x0F; printf("%d", (unsigned char)~c); What is printed?
- int i = 0; if (0 && i++) ; if (1 || i++) ; printf("%d", i); What is printed?