ProgrammingHard
#define SQ(x) ((x) * (x)) printf("%d", SQ(2 + 1)); What is printed?
- A. 5
- B. 7
- C. 6
- D. 9
Correct answer: D. 9
The parentheses in the macro body make the argument 2 + 1 expand to (2 + 1) * (2 + 1) = 9.
More C Programming questions
- #define ADD(a, b) a + b printf("%d", ADD(1, 2) 3); What is printed?
- char grid[2] = {"ab", "cd"}; printf("%c", grid[1][0]); What is printed?
- struct S { int a; char c; } arr[2] = {{1}}; printf("%d", arr[1].a); What is printed?
- int a[5] = {[2] = 7, 9}; printf("%d", a[3]); What is printed?
- char s = "hi"; s++; printf("%s", s); What is printed?
- int x = 1; { int x = 2; printf("%d", x); } printf("%d", x); What is printed?