ProgrammingHardTCS NQT · Infosys

char *p = "xyz"; char a[] = "xyz"; a[0] = 'Q'; printf("%s", a); What is printed?

  1. A. Qyz
  2. B. xyz
  3. C. Qy
  4. D. QQz

Correct answer: A. Qyz

a is a modifiable array initialised from the string, so writing a[0] changes it to Qyz. The pointer p is not used in the output.

More C Programming questions

Exams that ask this topic