ProgrammingHardTCS NQT · Infosys

char s[] = "abc"; s[0] = 'x'; printf("%s", s); prints what?

  1. A. xbc
  2. B. abc
  3. C. xbcd
  4. D. bc

Correct answer: A. xbc

A char array initialised from a string literal is a modifiable copy, so writing s[0] changes it. The literal itself, when given as char *, would be the non-modifiable case.

More C Programming questions

Exams that ask this topic