program to reverse a string in cpp code example Example: Reverse string C++ reverse(str.begin(),str.end());