← Back to Pointers
Question 680
Swap Two Inventory Counts by Reference
Swap Two Inventory Counts by Reference
Write the body of voidswapCounts(int &shelfA, int &shelfB)so it swaps the two integers it is given. main is already written: it reads two integers from input (the count on shelf A, then the count on shelf B), callsswapCounts(a, b), and prints them. For the input: 12 30 the program must print exactly the output shown in Expected Output. Do not print anything inside swapCounts.
Expected Output:
shelfA=30 shelfB=12= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.