logo CodeStepByStep logo

swapPairsInPlace

Language/Type: C++ string return
Related Links:

Write a function named swapPairsInPlace that accepts a string reference as a parameter and modifies that string so that each pair of adjacent letters will be reversed. If the string has an odd number of letters, the last letter is unchanged. For example, if a string variable s stores "example", the call of swapPairsInPlace(s); should change the string to "xemalpe". If s had been "hello there", the call would produce "ehll ohtree".

Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.