implemented the string reverse function using user input