Question: Define a structure called Contact with two string members: name and phoneNumber.c + + Write a sort function that takes a Contact pointer and size

Define a structure called Contact with two string members: name and phoneNumber.c++
Write a sort function that takes a Contact pointer and size of Contacts and sorts the Contacts pointed to by the pointer in ascending order based on the Contact names.
Write a binary search function that takes a Contact pointer, size of Contacts and a name and searches for the Contact name. The function must return the index where the contact was found or -1, if not found.
In main, ask the user how many Contacts to create and then dynamically allocate an array of Contacts of the specified size. Then, read that many names and phone numbers and store them in the Contacts array dynamically allocated.
Sort the contacts by name using the sort function and display all contacts: names and phone numbers. Then, read a name from the user and using the binary search function search for it and then print in main the name and phone number of the search contact, if found or that it was not found.
Delete the Contacts dynamically created when done.
Engine's power: 44 Engine's temperature: 45

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!