728x90 AdSpace

Latest Article



Implement DOUBLY LINK LIST in C++ Example Code




How to create Implement DOUBLY linked LIST in C++ Example Code ?
/*CREATION OF DOUBLY LINK LIST AND OUTPUT ON USER'S CHOICE*/

#include<iostream.h>
#include<conio.h>
class node
 {
  public:
 int data;
 char name[30];
 node *AP;
 node *AN;
  };
    void main()
    {
     node *hand1=new node();
     node *hand2=new node();
     node *temp=new node();
     char choice='y';
     clrscr();
//////////////////////CREATE LINKLIST WITH QEUEU//////////
       node *n1=new node();
       n1->AP=NULL;
       n1->AN=NULL;
       cout<<"INSERT DATA  :";
       cin>>n1->data;
       hand1=n1;
       hand2=n1;
       cout<<"You want to insert more Data y/n ?\n";
       choice=getch();
 while(choice=='y')
 {
   node *n1=new node();
   cout<<"INSERT DATA  :";
 cin>>n1->data;
 n1->AP=hand2;
 n1->AN=NULL;
 hand2->AN=n1;
 hand2=n1;
 cout<<"You want to insert more Data y/n ?\n";
 choice=getch();
}
/////////////////////////////////Output/////////////////////
  temp=hand2;
  cout<<endl<<endl<<"OUTPUT IS";
 while(temp)
 {
  cout<<endl;
  cout<<temp->data;
  temp=temp->AP;
 }
 getch();
  }

no image






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment