Problem description:You are given a phone book that consists of your friend's names and  their phone number. After that you will be given your friend's name  as query. For each query, print the phone number of your friend.The first line will have an integer N denoting the number of entries  in the phone book. Each entry consists of two lines: a name and the  corresponding phone number. After these, there will be some queries. Each query will contain name  of a friend. Read the queries until end-of-file.For each case, print Not found without quotes, if the friend has no  entry in the phone book. Otherwise, print the friend's name and phone  number. See sample output for the exact format.Sample input:3sam99912222tom11122222harry12299933samedwardharrySample output:sam=99912222Not foundharry=12299933My solution:int main()    {        map<string, string> PhoneList;    int n;    string name,ph,str;    while(n--)        {         cin>>name>>ph;         PhoneList[name] = ph;        }    while( getline (cin,t) )      {           cin>>str;          auto it = PhoneList.find(str);               if(it==PhoneList.end())                  cout<<Not Found\n;               else                  cout<<it->second;      }    return 0;}
Mapping phone numbers to names
c++;file system;search;hash table
There are several issues with your program, some of them rendering it non-functional. As it is a very simple one, it does not take much time to fix it, but as already specified by Edward, you should submit only working code that requires reviewing.1) Code aspectYou should try to keep you code as organized and homogeneous as possible. Usually, it is not required for homework, but it is good in a programmer's life:int main()    {        map<string, string> PhoneList;    int n;should be properly formatted likeint main() {       map<string, string> PhoneList;   int n;Try to leave blanks between operators and operands, as this will increase readability:string name,ph,str;should be replaced withstring name, ph, str;2) Variable declaration closer to usageC++ allows you to declare your variables anywhere before they are actually used and it is a good idea to be as close as possible. The first part of your program may look like this:int n;cout << Provide number of entries: ;cin >> n;map<string, string> PhoneList;while (n --){    string name, phone;    // this is added just to see something relevant on the screen - it might be removed    cout << Name  << (n + 1) << :\n;    cin >> name;    cout << Phone  << (n + 1) << :\n;    cin >> phone;    PhoneList[name] = phone;}3) getLine requires a cin.ignore() before, as it will catch a newline for a previously entered phone (at least when testing manually)Finally, a version of your program with all improvements made:// Example program#include <iostream>#include <string>#include <map>using namespace std;int main() {        int n;    cout << Provide number of entries: ;    cin >> n;    map<string, string> PhoneList;    while (n --)    {        string name, phone;        cout << Name  << (n + 1) << :\n;        cin >> name;        cout << Phone  << (n + 1) << :\n;        cin >> phone;        PhoneList[name] = phone;    }    string str;    cin.ignore();    while(getline(cin, str))    {         auto it = PhoneList.find(str);        if (it == PhoneList.end())            cout << Not Found\n;        else            cout << it->second << \n;    }}This is tested in cpp.sh