completed sudo code for reverse print function