ProgrammingHardTCS NQT · Infosys
#define N 3 and int a[N * 2 + 1]; What is sizeof a / sizeof a[0]?
- A. 6
- B. 7
- C. 5
- D. 3
Correct answer: B. 7
N * 2 + 1 expands to 3 * 2 + 1 = 7, so the array has seven elements. The macro is plain text, which is why the expression is evaluated after substitution.
More C Programming questions
- int x = 5, y = 3; What does printf("%d", x & y | 4 ^ 1) print?
- unsigned int n = 3u; int k = -1; if (k > n) printf("yes"); else printf("no"); What is printed?
- Which type reliably holds the sum 1 + 2 + ... + 100000 = 5000050000?
- What is (uint32t)~0u >> 28?
- int g[2][3] = {1, 2, 3, 4}; What is g[1][1] + g[0][2]?
- uint8t a = 200; a = a + a; What is a?