ProgrammingHardTCS NQT · Infosys
int x = 0, y = 1; What does printf("%d", !x == y) print?
- A. 0
- B. 1
- C. 2
- D. compile error
Correct answer: B. 1
! binds tighter than ==, so !x is 1 when x is 0. Then 1 == y is 1 == 1, which is true and prints 1.
More C Programming questions
- 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?
- unsigned char a = 255; printf("%d", a == -1); What is printed?