Be the first user to complete this post

  • 0
Add to List

Reverse a String using Recursion

Objective: Given a String, write a recursive program to reverse it.

Example:

Original String: tutorial horizon
Reversed String: noziroh lairotut

Approach:

  • Take the first character out of the string, add it to the end of result of the remaining string.
  • Make a recursive call to remaining string.

Code:


Output:

Original String: tutorial horizon
Reversed String: noziroh lairotut



Also Read: