ProgrammingHardTCS NQT · Infosys
int m[2][3] = {{1, 2, 3}, {4, 5, 6}}; int (*p)[3] = m; printf("%d", *(*(p + 1) + 2)); prints what?
- A. 5
- B. 6
- C. 3
- D. 4
Correct answer: B. 6
p + 1 points to the second row {4, 5, 6}. Dereferencing gives that row's first element, and adding 2 reaches its third element, which is 6.
More C Programming questions
- Which statement about sizeof is correct when x is an int variable initialised to 5?
- char s[] = "hello"; printf("%zu %zu", sizeof s, strlen(s)); prints what?
- char names[] = {"ab", "cde", "f"}; What is strlen(names[0]) strlen(names[1]) + strlen(names[2])?
- int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int (ops[])(int, int) = {add, sub, add}; int r = 10; for…
- uint32t a = 4000000000u; uint32t s = a + a; What is s?
- uint32t lo = 3000000000u, hi = 3500000000u; uint32t mid = (lo + hi) / 2; What is mid?