reverse a string using functions of swap & reverse