Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <map>
    using namespace std;
    int main ()
    {
    map<char, int> MapData;
    map<char, int> :: iterator Iter;
    MapData['P'] = 250;
    MapData['Q'] = 150;
    MapData['R'] = 350;
    for (map<char, int> :: iterator Iter = MapData.begin(); Iter != MapData.end(); ++Iter)
    cout << Iter -> first << " => " << Iter -> second << '\n';
    return 0;
    }
    1. P => 250
      Q => 150
      R => 350
    2. Q => 150
      P => 250
      R => 350
    3. R => 350
      P => 250
      Q => 150
    4. All of above
    5. None of these
Correct Option: A

In this program, We used the map template and the we used the begin operation and then we are printing the elements.



Your comments will be displayed only after manual approval.