728x90 AdSpace

Latest Article

Singly circular Linked list in C++ with Example Code




How to implement Single circular Link list in C++ Programming with Example Code?
//INSERTION OF DATA AT BOTTOM IN SINGLE CICULAR LINK LIST//

#include<iostream.h>
#include<conio.h>
class node
 {
  public:
      int data;
      node *address;
 };
   void main(void)
   {
     node *handler=new node();
     node *temp1=new node();
     node *temp2=new node();
     char ch;
     clrscr();
//////////////////////CREATE LINKLIST WITH QEUEU//////////
     node *n1=new node();
     node *temp=new node();
     handler=n1;
     n1->address=n1;
     cout<<"INSERT DATA  :";
     cin>>n1->data;
     temp=handler;
     cout<<"To insert more data press Y"<<endl;
     ch=getch();
       while(ch=='y')
 {
   node *n1=new node();
   cout<<"INSERT DATA  :";
   cin>>n1->data;
   n1->address=temp->address;
   temp->address=n1;
   temp=n1;
   cout<<"To insert more data press Y"<<endl;
   ch=getch();
 }
/////////////////////////OUTPUT//////////////////////
 temp1=handler;
 cout<<endl<<"THE OUTPUT IS";
  while(temp1->address!=handler)
   {
    cout<<endl;
    cout<<temp1->data;
    temp1=temp1->address;
   }
 cout<<endl<<temp1->data;
//////////INSERTION AT TOP//////////////////////////
 cout<<endl<<"ENTER DATA TO INSERT:";
 cin>>n1->data;
 cout<<endl<<endl<<"LINK LIST AFTER INSERTION";
    temp2=handler;
   while(temp2->address!=handler)
    {
  cout<<endl<<endl;
  cout<<temp2->data;
  temp1=temp2->address;
    }
 temp2->address=n1->address;
 temp2->address=n1;
getch();
}
no image





  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Top