ProgrammingHard

char a[5] = "hi"; printf("%d", a[4]); What is printed?

  1. A. 32
  2. B. garbage
  3. C. 104
  4. D. 0

Correct answer: D. 0

Elements left out of an initialiser are set to zero, so the unused tail of a is zero. Printing a[4] as an int gives 0.

More C Programming questions

Exams that ask this topic