← Back to Pointers
Question 681
Swap a Morning and Evening Temperature with Pointers
Swap a Morning and Evening Temperature with Pointers
Write the body of voidswapTemps(int *morning, int *evening)so it swaps the two integers the POINTERS point at. main is already written: it reads two integers from input (the morning temperature, then the evening temperature), passes their addresses withswapTemps(&morning, &evening), and prints them. For the input: 41 68 the program must print exactly the output shown in Expected Output. Do not print anything inside swapTemps.
Expected Output:
morning=68 evening=41= 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.