In this program, we will take a string as input and replace the second occurrence of any char with the special character $.
Steps to solve the program
- Take a string as input and create an empty string.
- Using For loop add each character of the given string to the empty string.
- If a character repeats then do not add that character add $ instead.
- Print the output.
Output :