Procedure to delete a node from any position in a linked list.
Deleting the Head Node :
voiddeleteFirst(struct node *ptr) { first =ptr -> next;free(ptr);}
Deleting a Node from Any Index :
voiddelete(struct node *ptr,int index) {// If node to be deleted is the head nodeif (index ==1) { head =ptr -> next;free(ptr); }// Deleting other nodeselse {for (int i =0; i < index -2; i++) { ptr =ptr -> next; }// Find the node to be deletedstruct node *toDelete =ptr -> next;// Replace the linkptr -> next =toDelete -> next;// Deallocate the memoryfree(toDelete); }}