← Back to Streams
Question 633
Table Row Helper
Table Row Helper
Write a functionvoid printRow(ostream& out, const string& name, int qty, double price)that writes one table row tooutand ends it with a newline. The row has three columns with no separator characters between them: 1.nameleft-aligned in 8 columns 2.qtyright-aligned in 4 columns 3.priceright-aligned in 8 columns, always with exactly 2 decimal places Output ofprintRow(cout, "apple", 5, 1.25): apple 5 1.25 Do NOT write a main function.
Expected Output:
apple 5 1.25 banana 12 0.50 kiwi 100 12.50
= newline. The output ends with a newline — print one after the last line.
Hints3 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.