Oop 7
Oop 7
Oop 7
Title: -Write a program in C++ to use map associative container. The keys will be the names of states
and the values will be the populations of the states. When the program runs, the user is prompted to
type the name of a state. The program then looks in the map, using the state name as an index and
returns the population of the state.
.
Roll No:-
Class:-SE Computer
Date:-
****************************************************************************/
Program-
#include <iostream>
#include <map>
#include <string>
#include <utility>
int main()
mapType populationMap;
populationMap.insert(mapType::value_type("US", 310));
populationMap.insert(mapType::value_type("Indonesia", 234));
populationMap.insert(make_pair("Brasil", 193));
populationMap.insert(make_pair("Pakistan", 170));
populationMap.erase(iter);
string country("Indonesia");
iter = populationMap.find(country);
populationMap.clear();
/*Output:-
Size of populationMap: 5
Brasil: 193 million
China: 1339 million
India: 1187 million
Indonesia: 234 million
Pakistan: 170 million
Indonesia's populations is 234 million*/