Singly Linked List in C

Here you will learn about singly linked list in C.

What is Singly Linked List (SLL)?

The simplest kind of linked list is a singly liked list (SLL) which has one link per node. It has two parts, one part contains data and other contains address of next node. The structure of a node in a SLL is given as in C:

 

 

The program is given below that will perform insertion, deletion and display a singly linked list.

Singly Linked List in C

 

Output
—- Singly Linked List(SLL) Menu —-
1.Insert
2.Display
3.Delete
4.ExitEnter your choice(1-4):1—- Insert Menu —-
1.Insert at beginning
2.Insert at end
3.Insert at specified position
4.ExitEnter your choice(1-4):1
Enter data:4—- Singly Linked List(SLL) Menu —-
1.Insert
2.Display
3.Delete
4.ExitEnter your choice(1-4):2
The linked list is:
4->

—- Singly Linked List(SLL) Menu —-
1.Insert
2.Display
3.Delete
4.Exit

Enter your choice(1-4):4

Category: DSA

14 thoughts on “Singly Linked List in C

  1. uBunny

    Great tutorial. Can you explain what is Doubly linked list and how to add elements in it?

    Reply
  2. divya goel

    whoa !!.. awesome program but it's countering a problem while displaying the list it says list is empty though i've inserted numbers in the beginning and end both then i inserted at desired position n then chose option 4 i.e display it saying that list is empty and then it says press any key to continue i've done accordingly but it repeatedly says press any key to cont. … agn n agn so problem is in d code of display please can ya wrk on it ??…

    Reply
    1. Neeraj Mishra

      What problem you are getting, tell me the inputs that you have entered?

      Reply
  3. Sheharyar

    can i have the link of singly & doubly linkd list in c++??
    Neeraj!!

    Reply
  4. juls

    Can you make a linked list that has search options ? Thanks 🙂

    Reply
  5. Vineeth

    In the for loop for(i=1;i<pos-1;pos++)
    Why are we incrementing the pos? Shouldn't we be incrementing i?

    Reply
    1. Admin Post author

      It was a little mistake, now I have corrected it. Thanks for mentioning.

      Reply

Leave a Reply

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