ProgrammingHardTCS NQT · Infosys
#define DOUBLE(x) (x + x). What does printf("%d", DOUBLE(2) * 3) print?
- A. 8
- B. 6
- C. 12
- D. 10
Correct answer: C. 12
The macro expands to (2 + 2) * 3 = 12. The outer parentheses in the macro body are what make the expansion safe here.
More C Programming questions
- uint8t x = 0x90; uint8t y = x & (uint8t)(x - 1); What is y?
- int f(int n) { if (n == 0) return 0; return n % 2 + f(n / 2); } What is f(37)?
- For unsigned int i = 3; i >= 0; i--, what happens to the loop body?
- char a[] = "hi"; char b[] = "hi"; What does a == b evaluate to?
- What does printf("%d", '0' < '9') print?
- What does printf("%d", 6 % 4 2) print?