Write a C program to create a singly linked list of n nodes and insert a node in the beginning of the singly linked list. How to insert a node in the beginning of the singly linked list. Algorithm to insert a node at the beginning of Singly linked list. Steps to insert a new node at the start of a singly linked list.

Required knowledge
Basic C programming, Functions, Singly Linked list, Dynamic memory allocation
Algorithm to insert node at the beginning of singly linked list
Algorithm to insert node at the beginning of Singly Linked List Being: createSinglyLinkedList (head) alloc (newNode) If (newNode == NULL) then write ('Unable to allocate memory') End if Else then read (data)wo newNode.data ← data newNode.next ← head head ← newNode End else End
Steps to insert node at the beginning of singly linked list
- Create a new node, say newNode points to the newly created node.
- Link the newly created node with the head node, i.e. the newNode will now point to head node.
- Make the new node as the head node, i.e. now head node will point to newNode.
Program to insert node at the beginning of singly linked list
Enter the total number of nodes: 4 Enter the data of node 1: 20 Enter the data of node 2: 30 Enter the data of node 3: 40 Enter the data of node 4: 50 SINGLY LINKED LIST CREATED SUCCESSFULLY Data in the list Data = 20 Data = 30 Data = 40 Data = 50 Enter data to insert at beginning of the list: 10 DATA INSERTED SUCCESSFULLY Data in the list Data = 10 Data = 20 Data = 30 Data = 40 Data = 50