Restore Stream State
hardQuestion 645Write a function void printMoney(ostream& out, double v) that writes a dollar sign followed by v with exactly two decimals and a newline ($1234.50 for 1234.5), then leaves out in exactly the state it found it.
The tests print 3.14159 through 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, so 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.