Javatpoint Logo
Javatpoint Logo

Program to find reverse of a string

Explanation

In this program, we need to find the reverse of the string. This can be done by iterating the string backward and storing each character from the original string into a new string.

Algorithm

  1. Define a string and another empty string to store the reversed string.
  2. Now, iterate the string from last and store a character from back into variable revString.
  3. At the end of the loop, revString will hold the reverse of the string.

Solution

Python

Output:

Original string: Dream big
Reverse of given string: gib maerD

C

Output:

Original string: Dream big
Reverse of given string: gib maerD

JAVA

Output:

Original string: Dream big
Reverse of given string: gib maerD

C#

Output:

Original string: Dream big
Reverse of given string: gib maerD

PHP

Output:

Original string: Dream big
Reverse of given string: gib maerD

Next Topic#




Please Share

facebook twitter google plus pinterest

Join Javatpoint Test Series

https://testseries.javatpoint.com
JavaTpoint offers Test Series on eLitmas, Amcat, Company Placement Papers, Programming Languages, SSC, Banking, Civil Services etc.

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA