map stl Question 9

Last Updated :
Discuss
Comments

What will be the output of the following C++ program?

#include <iostream>
#include <map>
using namespace std;
int main()
{
multimap<char, int> sample;

sample.insert(make_pair('a', 10));
sample.insert(make_pair('b', 20));
sample.insert(make_pair('b', 30));
sample.insert(make_pair('c', 40));
sample.insert(make_pair('c', 50));

cout << sample.rbegin()->first << " = " << sample.rbegin()->second;
}

c = 50

c = 40

b = 30

a = 10

Share your thoughts in the comments