ProgrammingModerateAccenture · Cognizant pattern

What is printed?

What is printed?
int a[2][3] = {{1, 2, 3}, {4, 5, 6}};
printf("%d %d", *(*(a + 1) + 2), **a + 1);
  1. A. 6 2
  2. B. 5 2
  3. C. 3 4
  4. D. 6 4

Correct answer: A. 6 2

*(a + 1) is row 1, and *(row1 + 2) is a[1][2] = 6. **a is a[0][0] = 1, and unary * binds tighter than +, so **a + 1 = 2. Reading it as **(a + 1) gives 4.

More C Programming questions

Exams that ask this topic