CJCoding With Joseph
15free / daySign inCreate account

A map<string, int> named stock has already been created with apple mapped to 3 and pear mapped to 5. Write an iterator loop from stock.begin() to stock.end() that prints one line per entry in the format key, colon, space, value (see Expected Output).

Each line ends with a newline. Do not use a range-based for loop — use begin()/end() and the -> operator.

Expected output

apple: 3
pear: 5

= newline. The output ends with a newline, so print one after the last line.

Hints2 available
Topics
STL ContainersIterators
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.