/*WAP to insert any from double linked list*/ #include<stdio.h> #include<conio.h> #include<stdlib.h> struct node { int data; struct node *llink; struct node *rlink; }; typedef struct node node; void insert_any(node *); void main() { node *header=NULL; int n; clrscr(); insert_any(header); getch(); } void insert_any(node *temphead) { int key; node *temp; node *temp1; printf("After which number you want to insert?????"); scanf("%d",&key); while(temphead->rlink!=NULL && temphead->data!=key) { temphead=temphead->rlink; } if(temphead->data!=key) { printf("Value not found insertion not possible"); } else { temp=(node *)malloc(sizeof(node)); printf("Enter data:"); scanf("%d",&temp->data); temp1=temphead->rlink; temp->llink=temphead; temp->rlink=temp1; temphead->rlink=temp; printf("Insert sucessfully\n"); if(temp1!=NULL) { temphead->llink=temp; } } }
WAP to insert any from double linked list
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment