ProgrammingHardTCS NQT · Infosys

int a[5]; int *p = &a[4]; printf("%td", p - &a[0]); What is printed?

  1. A. 5
  2. B. 4
  3. C. 3
  4. D. 0

Correct answer: B. 4

&a[4] minus &a[0] is the element distance 4. An off-by-one reading would print 5, the array length.

More C Programming questions

Exams that ask this topic