ProgrammingHard

char s[] = "xyz"; for (int i = 0; s[i]; i++) s[i] = (s[i] - 'a' + 3) % 26 + 'a'; printf("%s", s); What is printed?

  1. A. cde
  2. B. xyz
  3. C. abc
  4. D. bcd

Correct answer: C. abc

Each letter moves 3 places with wrap-around: x becomes a, y becomes b and z becomes c. All intermediate values are non-negative, so % behaves as expected.

More C Programming questions

Exams that ask this topic