×
Reviews 4.9/5 Order Now

Create a Program to Implement Phone Book System in C++ Assignment Solution.

July 15, 2024
Dr. Benjamin Hughes
Dr. Benjamin
🇬🇧 United Kingdom
C++
Dr. Benjamin Hughes holds a Ph.D. in Computer Science from the University of Cambridge and has over 10 years of experience in software development and programming education. With expertise in Templated Linked Lists, he has completed over 800 assignments with precision and efficiency, helping students across the globe excel in their programming coursework.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
Break your NetLogo model into simple procedures using functions for better readability. Use the ask command efficiently to control agents and optimize performance by minimizing unnecessary computations in the go procedure. Always test your model with small agent populations before scaling up.
News
LFortran Advances: LFortran, an open-source Fortran compiler, achieved compatibility with the PRIMA library in March 2025, enhancing support for numerical computing.

Instructions

Objective

Write a C++ homework to implement a phone book system.

Requirements and Specifications

program to implement phone book system in C++
program to implement phone book system in C++ 1

Source Code

#include "phentries.h" #include #include #include /* Create a new entry node */ PhEntry *phentries_create(int area_code, int phone_number, const char *last_name, const char *first_name) { PhEntry *entry; entry = (PhEntry *)malloc(sizeof(PhEntry)); entry->areaCode = area_code; entry->phoneNumber = phone_number; strcpy(entry->lastName, last_name); strcpy(entry->firstName, first_name); entry->nextPhEntry = NULL; entry->prevPhEntry = NULL; return entry; } /* Display an individual entry information */ void phentries_print_entry(PhEntry *entry) { printf("Area Code: %d\n", entry->areaCode); printf("Phone Number: %d\n", entry->phoneNumber); printf("Last Name: %s\n", entry->lastName); printf("First Name: %s\n", entry->firstName); } /* Insert a new entry on top of the list */ void phentries_insert_entry(PhEntry **entries, PhEntry *entry) { entry->nextPhEntry = *entries; if (entry->nextPhEntry != NULL) entry->nextPhEntry->prevPhEntry = entry; *entries = entry; } /* Find the entry that holds the given last name */ PhEntry *phentries_find_by_lastname(PhEntry *entries, char last_name[]) { PhEntry *current; current = entries; while (current != NULL) { if (strcmp(current->lastName, last_name) == 0) return current; current = current->nextPhEntry; } return NULL; } /* Find the entry that holds the given phone number*/ PhEntry *phentries_find_by_phone(PhEntry *entries, int area_code, int phone) { PhEntry *current; current = entries; while (current != NULL) { if (current->areaCode == area_code && current->phoneNumber == phone) return current; current = current->nextPhEntry; } return NULL; } /* Find the first entry that has the given area code */ PhEntry *phentries_find_by_area(PhEntry *entries, int area_code) { PhEntry *current; current = entries; while (current != NULL) { if (current->areaCode == area_code) return current; current = current->nextPhEntry; } return NULL; } /* Deallocate all entry nodes */ void phentries_delete_all(PhEntry **entries) { PhEntry *next; PhEntry *current; current = *entries; while (current != NULL) { next = current->nextPhEntry; free(current); current = next; } *entries = NULL; } /* Display all entries */ void ph_entries_print_all(PhEntry *entries) { PhEntry*current; current = entries; while (current != NULL) { printf("Area Code: %d, Phone: %d, Last Name: %s, First Name: %s\n", current->areaCode, current->phoneNumber, current->lastName, current->firstName); current = current->nextPhEntry; } }

Similar Sample

Explore our C++ assignment sample to understand how we tackle complex programming tasks. At ProgrammingHomeworkHelp.com, we provide clear, well-commented solutions that illustrate best practices in C++ programming. Whether it's basic syntax or advanced algorithms, our samples demonstrate our expertise in delivering high-quality assignments.