ProgrammingHardProduct-company MCQ pattern

Assume a 64-bit LP64 ABI. What is printed?

Assume a 64-bit LP64 ABI. What is printed?
int a[3][2] = {{1,2},{3,4},{5,6}};
int (*p)[2] = a + 1;
int *q = (int*)p;
q++;
printf("%d %d", (*p)[0], *q);
  1. A. 3 3
  2. B. 3 4
  3. C. 4 4
  4. D. 3 5

Correct answer: B. 3 4

p points at row 1 ({3,4}), so (*p)[0]=3. q starts as that row's first element address reinterpreted as int*; q++ moves one int forward to the second element of that row, value 4.

More C Programming questions

Exams that ask this topic