# include<iostream.h>

struct node{ int info;

                  node *next;};

void main(){

      node *list;

      int x;

      cout<<"INITIALIZE THE LIST:"<<endl;

      list=NULL;

      cout<<"Inserting node B at beginning of the list"<<endl;

      node *b;

      b=new node;

      cout<<"Enter the item: ";

      cin>>x;

      b->info=x;

      b->next=list;

      list=b;

      cout<<"Item inserted: "<<list->info<<endl;

      cout<<"Inseting the node E after the node B"<<endl;

      node *e;

      e=new node;

      cout<<"Enter the item: ";

      cin>>x;

      e->info=x;

      e->next=NULL;

      b->next=e;

      cout<<"Instered items in list are; "<<list->info<<" "<<list->next->info<<endl;

      cout<<"Insteting the node M between B and E "<<endl;

      node *m;

      m=new node;

      cout<<"Enter the item: ";

      cin>>x;

      m->info=x;

      m->next=e;

      b->next=m;

      cout<<"inserted items in list are: ";

      cout<<list->info<<" "<<list->next->info<<" "<<list->next->next->info<<endl;

      cout<<"Remove the middle node from list B,M,and E"<<endl;

      b->next=e;

      m->next=NULL;

      delete m;

      cout<<list->info<<" "<<list->next->info<<endl;

      cout<<"Remove the end node from list B E"<<endl;

      b->next=NULL;

      delete e;

      cout<<list->info<<endl;

      cout<<"Remove the first element from list B"<<endl;

      b=list;

      list=list->next;

      b->next=NULL;

      delete b;

}

 

 

 

 

1