Procedure to insert a node at a given index in a circular linked list.
voidinsert(struct node *ptr,int data,int postition) {// Creating a new node and assigning datastruct node *newNode; newNode = (struct node *)malloc(sizeof(struct node));newNode -> data = data; // If node is to be inserted before headif (position ==1) {// Checking if list is emptyif (head ==NULL) { head = newNode;head -> next = head; } // If a node already existselse {// Traverse to end of listwhile (ptr -> next != head) { ptr =ptr -> next; }ptr -> next = newNode;newNode -> next = head; } }// If node is to be inserted in any other indexelse {for (int i =0; i < postition -2; i++) { ptr =ptr -> next; }newNode -> next =ptr -> next;ptr -> next = newNode; }}