Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help: Write a program in c++ that uses an array of structures to hold con

ID: 3761873 • Letter: P

Question

Please help:

Write a program in c++ that uses an array of structures to hold contact information for your friends. The program should allow the user to enter as many friends as the user wants. Create functions to add or delete entries in the phone book and to print valid phone book entries. Do not display phone book entries that are invalid or NULL (0). You can assume that all people have unique names. Make sure you allocate and free memory as necessary.

Output example:

Phone Book Application

1) Add friend

2) Delete friend

3) Show phone book

What do you want to do: 1

First name: Bob

Last name: Smith

Phone number: 123-4567

Record added to the phone book

Explanation / Answer

#include<iostream.h>
#include<conio.h>
struct phbk
{
   char name[20];
   char pn;

};

void main()
{
   struct phbk e[100];
   int i=0,c;
   ans ='y';

   while(ans=='y')
   {
       cout<<"Phone Book Application"<<endl;
       cout<<"1)Add friend"<<endl;
       cout<<"2)Delete friend"<<endl;
       cout<<"3)Show phone book"<<endl;
       cout<<"what do you to do: ";
       cin>>c;
      
       switch(c)
       {
           case 1:
               cout<<"Enter name ";
               cin>>e[i].name;

               cout<<"Enter Phone number";
               cin>>e[i].pn;
               cout<<"Record added to the phone book";
               i++;
               break;
           case 2:
               e.clear();
               break;
           case 3:
                      
               for(j=0;j<i;j++)
               {
                   cout<<e[i].name<<endl;
                   cout<<e[i].pn<<endl;
               }
               break;      
       }
       cout<<"do you want to continue [y/n]";
       ans=getch();
   }
}