VOOZH about

URL: https://www.geeksforgeeks.org/c/menu-driven-program-for-all-operations-on-singly-linked-list-in-c/

⇱ Menu driven program for all operations on singly linked list in C - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Menu driven program for all operations on singly linked list in C

Last Updated : 5 Aug, 2025

A Linked List is a linear data structure that consists of two parts: one is the data part and the other is the address part. In this article, all the common operations of a singly linked list are discussed in one menu-driven program.

Operations to be Performed

  • createList(): To create the list with the 'n' number of nodes initially as defined by the user.
  • traverse(): To see the contents of the linked list, it is necessary to traverse the given linked list. The given traverse() function traverses and prints the content of the linked list.
  • insertAtFront(): This function simply inserts an element at the front/beginning of the linked list.
  • insertAtEnd(): This function inserts an element at the end of the linked list.
  • insertAtPosition(): This function inserts an element at a specified position in the linked list.
  • deleteFirst(): This function simply deletes an element from the front/beginning of the linked list.
  • deleteEnd(): This function simply deletes an element from the end of the linked list.
  • deletePosition(): This function deletes an element from a specified position in the linked list.
  • maximum(): This function finds the maximum element in a linked list.
  • mean(): This function finds the mean of the elements in a linked list.
  • sort(): This function sorts the given linked list in ascending order.
  • reverseLL(): This function reverses the given linked list.
  • display(): This function displays the linked list.
  • search(): This function searches for an element user wants to search.

Below is the implementation of the above operations:

Output:

Menu:

👁 Image

Insertion at the starting:

👁 Image

Insertion at the end:

👁 Image

Insertion at specific position:

👁 Image

Print the Linked List:

👁 Image

Maximum among Linked List:

👁 Image

Sorting the Linked List:

👁 Image

👁 Image

Reverse the Linked List:

👁 Image

Delete the first and last element with choice 5 and 6:

👁 Image
👁 Image

👁 Image

Searching the element with choice 12:

👁 Image
Comment