Question: this needs to be written in C Language... To start with: o you will take user input and o create a link list of 5
this needs to be written in C Language...
To start with: o you will take user input and o create a link list of 5 Areas as (area code 613 for Ottawa), (416 and 647 for Toronto), (519 for Windsor) and (905 for Niagra).
o Insert node at the end: You will insert each new area node at the end of the link list.
o You will print the list of area names and count number of listed areas in the link list each time you insert a new area node. This will show that you are inserting a new area node at the end and you can traverse through the link list and determine the length of the list.
Take user input and create a link list of 10 phone book entry with the existing 5 areas
o To start with, you will use a list of 10 random phone numbers from Greater Ontario with area codes according to the following struct.
o Insert node at the beginning: Insert each new PhEntry node at the beginning of the link list.
o You will print the listed 10 digit phone number and count number of listed PhEntry in the link list each time you insert a new PhEntry node. This will show that you are inserting a new node at the head and you can traverse through the link list and determine the length of the list.
You will implement deletion of a selected node from link list for option 4 below.
You will implement doubly link for the deletion of a selected node from link list for option 5 below
here is the code i have so far...
#include
#include
#include
typedef struct phEntry{
int areaCode;
int phone;
char firstName[20];
char lastName[20];
struct phEntry *next;
} PhEntry;
typedef struct area{
int areaCode;
char areaName[20];
struct area *next;
} Area;
Area* ACLinkList();
void ACprintList(Area* head);
PhEntry* PhLinkList();
void PhprintList(PhEntry* head);
int main(void){
Area* tHead = NULL;
tHead = ACLinkList();
if (tHead == NULL)
return 1;
ACprintList(tHead);
return 0;
}
Area* ACLinkList(){
Area* head = NULL;
Area* second = NULL;
Area* third = NULL;
Area* fourth = NULL;
Area* fifth = NULL;
head = malloc(sizeof(Area));
if (head==NULL)
return NULL;
second = malloc(sizeof(Area));
if (second==NULL)
return NULL;
third = malloc(sizeof(Area));
if (third==NULL)
return NULL;
fourth = malloc(sizeof(Area));
if (fourth==NULL)
return NULL;
fifth = malloc(sizeof(Area));
if (fifth==NULL)
return NULL;
head-> areaCode = 613;
head-> areaName[20] = "Ottawa";
head-> next = second;
second-> areaCode = 416;
second-> areaName[20] = "Toronto";
second-> next = third;
third-> areaCode = 647;
third-> areaName[20] = "Toronto";
third-> next = fourth;
fourth-> areaCode = 519;
fourth-> areaName[20] = "Windsor";
fourth-> next = fifth;
fifth-> areaCode = 905;
fifth-> areaName[20] = "Niagra";
fifth-> next = NULL;
return head;
}
void ACprintList(Area* head){
Area* current = head;
int count;
count = 0;
while (current != NULL){
count++;
printf("Count: %d, areacode: %d, areaname: %s ", count, current->areaCode, current->areaName);
current = current->next;
}
}
PhEntry* PhLinkList(){
PhEntry* head = NULL;
PhEntry* second = NULL;
PhEntry* third = NULL;
PhEntry* fourth = NULL;
PhEntry* fifth = NULL;
PhEntry* sixth = NULL;
PhEntry* seventh = NULL;
PhEntry* eighth = NULL;
PhEntry* ninth = NULL;
PhEntry* tenth = NULL;
head = malloc(sizeof(PhEntry));
if (head==NULL)
return NULL;
second = malloc(sizeof(PhEntry));
if (second==NULL)
return NULL;
third = malloc(sizeof(PhEntry));
if (third==NULL)
return NULL;
fourth = malloc(sizeof(PhEntry));
if (fourth==NULL)
return NULL;
fifth = malloc(sizeof(PhEntry));
if (fifth==NULL)
return NULL;
sixth = malloc(sizeof(PhEntry));
if (sixth==NULL)
return NULL;
seventh = malloc(sizeof(PhEntry));
if (seventh==NULL)
return NULL;
eighth = malloc(sizeof(PhEntry));
if (eighth==NULL)
return NULL;
ninth = malloc(sizeof(PhEntry));
if (ninth==NULL)
return NULL;
tenth = malloc(sizeof(PhEntry));
if (tenth==NULL)
return NULL;
/*head-> areaCode = ;
head-> phone = ;
head-> firstName[20] = ;
head-> lastName[20] = ;
head-> next = second;
second-> areaCode = ;
second-> phone = ;
second-> firstName[20] = ;
second-> lastName[20] = ;
second-> next = third;
third-> areaCode = ;
third-> phone = ;
third-> firstName[20] = ;
third-> lastName[20] = ;
third-> next = fourth;
fourth-> areaCode = ;
fourth-> phone = ;
fourth-> firstName[20] = ;
fourth-> lastName[20] = ;
fourth-> next = fifth;
fifth-> areaCode = ;
fifth-> phone = ;
fifth-> firstName[20] = ;
fifth-> lastName[20] = ;
fifth-> next = NULL;*/
return head;
}

1. If you choose option 1 you will have to enter 3 digit area code +area description. Insert each area node at the end of the area link list and print as detailed above If you choose option 2 you have to enter 3 digit area code +7 digit phone number and last name and first name of the person. Insert each PhEntry node at the beginning of the PhEntry link list and print as detailed above If you choose option 3 you will be able to modify an existing phone book entry based on 2. 3. a. 3 digit area code +7 digit phone number or b. last name of the person If you choose option 4 you will be able to delete an existing phone book entry based on a. 3 digit area code +7 digit phone number or b. last name of the person 4. 1. If you choose option 1 you will have to enter 3 digit area code +area description. Insert each area node at the end of the area link list and print as detailed above If you choose option 2 you have to enter 3 digit area code +7 digit phone number and last name and first name of the person. Insert each PhEntry node at the beginning of the PhEntry link list and print as detailed above If you choose option 3 you will be able to modify an existing phone book entry based on 2. 3. a. 3 digit area code +7 digit phone number or b. last name of the person If you choose option 4 you will be able to delete an existing phone book entry based on a. 3 digit area code +7 digit phone number or b. last name of the person 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
