Linked List Implementation in C++
π Overview This is a C++ program that implements a Singly Linked List with the following functionalities: Insert nodes at the tail (end of the list). Display the current list . Delete a node by specific value . Provides an interactive menu driven approach for user input.
π Features
β
Insert elements at the end of the linked list .
β
Delete a specific element from the list.
β
Display the linked list in the format: 10 > 20 > 30 > NULL
β
Handles cases like:
Deleting the head node .
Deleting a middle or last node .
Trying to delete a non existent value .
Deleting from an empty list .
β
User friendly menu based interaction.
β
Screen clearing (system("cls")) for a cleaner interface.
./linkedlist π₯οΈ Program Menu Once you run the program, you will see:
Enter A to insert value in link list Enter B to display values of link list Enter C to delete a value from the link list β Insertion
Enter a Number you want to enter in the link list: 10 Do you want to enter another number? (Enter 'y'/'n'): y Enter a Number you want to enter in the link list: 20 Do you want to enter another number? (Enter 'y'/'n'): n β Displaying List rust
10 > 20 > 30 > NULL β Deleting an Element
Enter a Number you want to delete from the link list: 20 Node with value 20 has been deleted. Updated Linked List: 10 > 30 > NULL π Functions Explanation πΉ Insert at Tail (tail(int d)) Adds a new node at the end of the list. If the list is empty, the new node becomes head. πΉ Delete a Node (del(int target)) Searches for the target value. If found: Updates the previous node's next pointer. Deletes the target node from memory. If the target is not found, prints "Value not found in list". πΉ Display (display()) Traverses the linked list and prints values. π» Example Execution
Enter A to insert value in link list Enter B to display values of link list Enter C to delete a value of link list A Enter a Number you want to enter in the link list: 5 Do you want to enter another number? (Enter 'y'/'n'): y Enter a Number you want to enter in the link list: 15 Do you want to enter another number? (Enter 'y'/'n'): n B 5 > 15 > NULL C Enter a Number you want to delete from the link list: 5 Node with value 5 has been deleted Updated Linked List: 15 > NULL β‘ Author π€ Zain ul Abidin π§ Contact: https://github.com/zaiinbaloch