Arrays and strings · Exercise 3 of 100
String Reversal
To reverse a word, read its letters from the last position back to the first. Write each letter as you visit it so that the new word contains all the original letters in the opposite order.
Try it yourself
A sign maker reads the lowercase word stressed from right to left. What word does she write?
One-step hint
Put a pencil under the final d. Copy one letter at a time as you move left, giving each repeated letter its own turn.
Worked solution
- Start at the final d and move left through e, s and s to write dess.
- The remaining letters in reverse order are e, r, t and s. Adding them gives desserts.