← Back to Streams
Question 645
Restore Stream State
Restore Stream State
Write a functionvoid printMoney(ostream& out, double v)that writes a dollar sign followed byvwith exactly two decimals and a newline ($1234.50for 1234.5), then leavesoutin exactly the state it found it. The tests print3.14159through the same stream afterwards (see Expected Output). Do NOT write a main function.
Expected Output:
$1234.50 3.14159 2.5 $1.00 100
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Streamsostream
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.