ProgrammingHardTCS NQT · Accenture

The words of "the sky is blue" are reversed in order (the words themselves are kept). The procedure below does this and prints the result. What is printed?

The words of "the sky is blue" are reversed in order (the words themselves are kept). The procedure below does this and prints the result. What is printed?
split the sentence into words; reverse the list; join with single spaces
Print result
  1. A. eulb si yks eht
  2. B. eht yks si eulb
  3. C. blue is sky the
  4. D. the sky is blue

Correct answer: C. blue is sky the

Reversing the list of words gives blue is sky the. Reversing the whole string reverses the letters too, reversing each word keeps the word order, and the original sentence is unchanged.

More Pseudocode and Code Tracing questions

Exams that ask this topic