ProgrammingHardTCS NQT · Infosys
#define MIN(a,b) ((a)<(b)?(a):(b)). What does printf("%d", MIN(MIN(3,1),2)) print?
- A. 1
- B. 2
- C. 3
- D. 0
Correct answer: A. 1
The inner MIN gives 1, and then MIN(1,2) gives 1. The fully parenthesised macro body makes nested use safe.
More C Programming questions
- int x = 5; printf("%d", x > 3 ? x - 3 : x + 3); What is printed?
- What does printf("%d", (4, 5) 2) print?
- 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?