ProgrammingHard

char s[] = "abcd"; int n = strlen(s); for (int i = 0; i < n / 2; i++) { char t = s[i]; s[i] = s[n - 1 - i]; s[n - 1 - i] = t; } printf("%c", s[0]); What is printed?

  1. A. a
  2. B. b
  3. C. c
  4. D. d

Correct answer: D. d

The reversal puts the last letter first, so s[0] becomes 'd'.

More C Programming questions

Exams that ask this topic