Posts

Showing posts from May, 2014

ALL IN ONE PROGRAM FOR LINKED LIST

Image
#include<iostream> #include<conio.h> using namespace std; struct node { int info; node *next; }*start=NULL; int disp(); int insert() { node *ptr=new node; cout<<"\nEnter info part : "; cin>>ptr->info; cout<<endl<<"+----------------------+\n| 1 | At end of list   |\n| 2 | At begin of list |\n| 3 | Before a node    |\n+----------------------+\nChoice : "; int ch1; cin>>ch1; switch(ch1){ case 1: if(start==NULL) { start=ptr; ptr->next=NULL; } else { node *ntr=new node; for(ntr=start;ntr->next!=NULL;) { ntr=ntr->next; } ntr->next=ptr; ptr->next=NULL; } break; case 2: if(start==NULL) { start=ptr; ptr->next=NULL; } else { ptr->next=start; start=ptr; } break; case 3: if(start==NULL) { cout<<"List is empty"; start=ptr; ptr->next=NULL; } else { cout<<"