Singly Linked List Program in C

Singly Linked List Program in C

Here you will learn and get the example code of Singly linked list program in c programming using data structure.

Singly Linked List

A singly linked list is a linear data structure consisting of nodes, each containing data and a reference to the next node. The last node’s reference is null. This helps store and organize data in a list-like manner.
Singly Linked List Program in C
The following program performing the insertion, delete, display data in Singly linked list.

Singly Linked List Program in C example


Output

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 1
Enter data to insert: 5
Data inserted successfully.

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 1
Enter data to insert: 10
Data inserted successfully.

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 1
Enter data to insert: 15
Data inserted successfully.

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 1
Enter data to insert: 20
Data inserted successfully.

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 2
Linked List: 5 -> 10 -> 15 -> 20 -> NULL

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 3
Enter value to delete: 15
Node deleted successfully.

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 2
Linked List: 5 -> 10 -> 20 -> NULL

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 5

Invalid choice! Try again.

Linked List Menu:
1. Insert node
2. Display list
3. Delete a node
4. Exit
Enter your choice: 4

Exiting

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top