Question: S THE DIGIT SWAP PROBLEM Write a function named swapDigitPairs() that accepts a positive integer n as an input-output parameter which is changed to a
S THE DIGIT SWAP PROBLEM Write a function named swapDigitPairs() that accepts a positive integer n as an input-output parameter which is changed to a new value similar to n's but with each pair of digits swapped in order. For example int n 482596; int oldswapDigitPairs(n); This returns 482597 but changes n to 845269. Notice that the 9 and 6 are swapped, as are the 2 and 5, and the 4 and 8. If the number contains an odd number of digits, leave the leftmost digit in its original place. For example: n 1234567; old swapDigitPairs(n); cout " "
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
