Question PRG-CPP-0009
MediumWhat is the output of this program?
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
map<string, int> m;
m["banana"]++;
m["apple"]++;
m["apple"]++;
for (auto &p : m) cout << p.first << ":" << p.second << " ";
return 0;
}
- A.
banana:1 apple:2
- B.
apple:2
- C.
apple:1 banana:1
- D.
apple:2 banana:1
Sign up free to see the answer and a step-by-step explanation.