What will be the output of the following C++ code?
#include <iostream>
#include <map>
using namespace std;
int main ()
{
map<char, int> mymap;
map<char, int> :: iterator it;
mymap['b'] = 100;
mymap['a'] = 200;
mymap['c'] = 300;
for (map<char, int> :: iterator it = mymap.begin(); it != mymap.end(); ++it)
cout << it -> first << " => " << it -> second << '\n';
return 0;
}
#include <iostream>
#include <map>
using namespace std;
int main ()
{
map<char, int> mymap;
map<char, int> :: iterator it;
mymap['b'] = 100;
mymap['a'] = 200;
mymap['c'] = 300;
for (map<char, int> :: iterator it = mymap.begin(); it != mymap.end(); ++it)
cout << it -> first << " => " << it -> second << '\n';
return 0;
}A. a => 200
c => 300
B. a => 200
b => 100
C. a => 200
b => 100
c => 300
D. a => 200
Answer: Option C

Join The Discussion