Question: Write a C++ function to add a node to the end of a linked list Your function takes two arguments-the head of the linked list

Write a C++ function to add a node to the end of a linked list Your function takes two arguments-the head of the linked list and the value num to be added. Your function should return the head of the linked list. If the list is empty, set the head to point to the new node and return the head pointer. Example: Initial Array: 4->2->3, key 5 Array After Function Call: 4->2->3->5 node* AddNode (node ?ead, int num); The linked list structure: struct node int key node *next; Hi For example Test Result / head2 // AddNode (head, 0) // AddNode (head, 2) // AddNode (head, 2) // AddNode(head, 4) // AddNode(head, 7) 2-> 0?2?2?4?7
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
