ProgrammingHardGATE CS · Product company OA

With 4-byte int, what is printed?

With 4-byte int, what is printed?
typedef int Row[3];
Row m[2] = {{1, 2, 3}, {4, 5, 6}};
Row *p = m;
printf("%zu %d", sizeof(Row), (*++p)[1]);
  1. A. 4 5
  2. B. 12 2
  3. C. 8 5
  4. D. 12 5

Correct answer: D. 12 5

Row is a typedef for int[3], so sizeof(Row) is 12 and Row * is a pointer to a whole row. ++p moves to m[1], and (*p)[1] is 5. '12 2' forgets the ++; '4' treats Row as a single int.

More C Programming questions

Exams that ask this topic