Last Updated :
10 Apr, 2024
unordered_map<string, int> ump;
ump[\"triangle\"] = 3;
ump[\"rectangle\"] = 4;
ump[\"pentagon\"] = 5;
ump[\"hexagon\"] = 6;
ump.insert(make_pair(\"rhombus\", 4));
if(ump.find(\"rhombus\") != ump.end())
cout << \"present\";
else
cout << \"not present\";
Predict the output for the above code snippet
(A) present
(B) not present
Answer: (A)
Explanation: unordered_map_name[key] = value – value is assigned to key in the map
insert() function can also be used to assign value to the corresponding key.
Share your thoughts in the comments
Please Login to comment...