Examveda

What will be the output of the following C++ code?
#include <iostream>
#include <map>
using namespace std;
int main ()
{
    try {
        map<char, int> mymap;
        map<char, int> :: iterator it;
        mymap['a'] = 50;
        mymap['b'] = 100;
        mymap['c'] = 150;
        mymap['d'] = 200;
        it = mymap.find('b');
        mymap.erase (it);
        mymap.erase (mymap.find('d'));
        cout << mymap.find('a') -> second << '\n';
    }
    catch (...) 
    {
        cout << "Unknown exception: " << endl;
    }
    return 0;
}

A. 50

B. 100

C. 150

D. Exception

Answer: Option A


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it