CJCoding With Joseph
15free / daySign inCreate account

Table Row Helper

Write a function void printRow(ostream& out, const string& name, int qty, double price) that writes one table row to out and ends it with a newline. The row has three columns with no separator characters between them:
1. name left-aligned in 8 columns
2. qty right-aligned in 4 columns
3. price right-aligned in 8 columns, always with exactly 2 decimal places

Output of printRow(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
Topics:
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.