Write a function InsertCustomer that inserts a node at the e
Write a function InsertCustomer that inserts a node at the end of the linked list. Assume that the function receives a pointer (Head) which points to the first node of the linked list as an argument. Within the InsertCustomer function, the user enters the information about the customer node to be inserted into the linked list. Write a function PrintCustomerList the prints the values of all the nodes of the linked list on the screen starting from the last to the first using recursion. The function receives a pointer (Head) which points to the first node of the linked list as an argument.
Solution
Here goes the solution for Question 3.
Code:
struct node{
int data;
Struct node *next;
}
void InsertCustomer(node *head) {
//create a link
struct node *link = (struct node*) malloc(sizeof(struct node));
cout<<\"Enter data\";
int data=0;
cin>>data;
//give the data to the link
link->data = data;
//traverse to the end of the list
while(head->next!= NULL){
head=head->next;
}
assign the link to the next of the last node in the list
head->next=link;
link->next=NULL;
}
Explanation:
