Example 78: Reverse a String

Learn how to reverse a string.


Write a function that takes in a string as input and reverses it. It should also print the reversed string on the console.


Input Output
To err is human namuh si rre oT
But to really mess things up pu sgniht ssem yllaer ot tuB
One needs to know C C wonk ot sdeen enO

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.