69
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
- Define a string and another empty string to store the reversed string.
- Now, iterate the string from last and store a character from back into variable revString.
- 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#