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.
Original string: Dream big
Reverse of the string: big maerD
ALGORITHM
- STEP 1: START
- STEP 2: DEFINE String string = "Dream big"
- STEP 3: DEFINE reversedStr = " "
- STEP 4: SET i =string.length()-1. REPEAT STEP 5 to STEP 6 UNTIL i>=0
- STEP 5: reversedStr = reversedStr + string.charAt(i)
- STEP 6: i = i - 1
- STEP 7: PRINT string.
- STEP 8: PRINT reversedStr.
- STEP 9: END
Program:
Output: