ProgrammingHardGATE CS · Product company OA

With 4-byte int, what is printed?

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

Correct answer: C. 8 8 12

*p is the whole array a, so (*p)[1] = 8 and sizeof *p = 12. **p is a[0] = 7, and + 1 applies after the dereference, giving 8, not a[1] + 1. '8 8 8' treats *p as a pointer.

More C Programming questions

Exams that ask this topic