/* In this program we are performing the insertions at the left side of specific node */ #include #include struct node { int data; node *next; }; class linklist { private: node *start; node *current; public: linklist() { start=NULL; current=NULL; } void insertnode(int n) { if(start==NULL) { start = new node; start->data=n; start->next=NULL; } else { current=start; if(current!=NULL) { while(current->next!=NULL) { current=current->next; } current->next=new node; current=current->next; current->data=n; current->next=NULL; } } } void insert(int N) { node *previos; node *curent=start; node *temp = new node; temp -> data = N; temp -> next = NULL; //here insertion will take place at left of 30 while(curent!=NULL && curent->data!=30) { previos = curent; curent = curent->next; } previos->next = temp; temp->next = curent; } void LRead(void) { while(start!=NULL) { cout<data<<' '; start=start->next; //copy the address of next node in start } } }; void main(void) { clrscr(); linklist r; r.insertnode(10); r.insertnode(20); r.insertnode(30); r.insertnode(40); r.insertnode(50); r.insert(35); r.LRead(); getch(); }