Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void add_node(Node *head)
- {
- int position, count=0, i=1;
- printf("enter the position after that place new node will be inserted : ");
- scanf("%d", &position);
- Node *temp;
- temp = head;
- while(temp != NULL)
- {
- count++;
- temp = temp->next;
- }
- if(position>count){
- printf("Invalid selection!!!\n");
- }
- else
- {
- temp = head;
- while(i<position)
- {
- temp = temp->next;
- i++;
- }
- Node *new_node = (Node *)malloc(sizeof(Node));
- printf("\nEnter Node item for the perticular position : ");
- scanf("%d", &new_node->data);
- new_node->next = temp->next;
- temp->next=new_node;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement