C Exercises: Insert new node at the beginning in a doubly linked list
3. Insert at Beginning of Doubly Linked List
Write a program in C to insert a node at the beginning of a doubly linked list.
Visual Presentation:

Sample Solution:
C Code:
Sample Output:
Doubly Linked List : Insert new node at the beginning in a doubly linked list : ------------------------------------------------------------------------------------ Input the number of nodes : 3 Input data for node 1 : 2 Input data for node 2 : 5 Input data for node 3 : 8 Data entered in the list are : node 1 : 2 node 2 : 5 node 3 : 8 Input data for the first node : 1 After insertion the new list are : node 1 : 1 node 2 : 2 node 3 : 5 node 4 : 8
Flowchart:

DlListcreation() :

DlLinsertNodeAtBeginning() :

displayDlList() :

For more Practice: Solve these Related Problems:
- Write a C program to insert a node at the beginning of a doubly linked list only if its value is less than the current head’s value.
- Write a C program to insert multiple nodes at the beginning of a doubly linked list in a loop and then display the list.
- Write a C program to insert a node at the start of a doubly linked list using a recursive function to update the head pointer.
- Write a C program to insert a node at the beginning and then immediately verify the circularity of the list by counting nodes.
C Programming Code Editor:
Previous: Write a program in C to create a doubly linked list and display in reverse order.
Next: Write a program in C to insert a new node at the end of a doubly linked list.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.