Circular Linked List Insertion
inserting a node at the beginning
use code from the create and display nodes and getnode function to assign data click here
- create a function inserbeg( )
- create a newnode,temp pointer
- call getnode( ) function to assign data to newnode

4.initialize head to temp pointer

5.move temp pointer to the last node, by replacing the temp address to the next node, until the condition (temp -> next != head)

6.link newnode of next address to head node (newnode->next=head)

7.move head pointer to newnode (head=newnode)

8.link temp of next address to the head node ,because head is now newnode

Program for inserting a node at the beginning
void cllinsertbeg()
{
node *newnode, *temp;
newnode = getnode();
if(head == NULL)
{
head = newnode;
newnode -> next = head;
}
else
{
temp = head;
while(temp -> next != head)
temp = temp -> next;
newnode -> next = head;
head = newnode;
temp -> next = head;
}
printf("\n Node inserted at beginning..");
}
inserting a node at the ending
use code from the create and display nodes and getnode function to assign data click here
- create a function inserend( )
- create a newnode,temp pointer
- call getnode( ) function to assign data to newnode

- initialize head to temp pointer

- move temp pointer to the last node, by replacing the temp address to the next node, until the condition (temp -> next != head)

6.link next address of temp node to newnode

7.link next address of newnode to the head

Program for inserting a node at the ending
void cllinsertend()
{
node *newnode, *temp;
newnode = getnode();
if(head == NULL )
{
head = newnode;
newnode -> next = head;
}
else
{
temp = head;
while(temp -> next != head)
temp = temp -> next;
temp -> next = newnode;
newnode -> next = head;
}
printf("\n Node inserted at end..");
}