Source Code:-
#include<iostream.h>
#include<conio.h>
#include<malloc.h>
struct node
{int info;
struct node *next;
}*start, *temp,*current;
void circular(int);
void circulardisplay();
void main()
{clrscr();
start=NULL;
int item,choice,location,element,position;
cout<<endl<<"Circular Singly Linked List by-Tarun Rawat\n";
again:
cout<<"\n1.Insert Item in Circular Linked List\n2.Display circular Linked List \n3.Exit\n";
cout<<"Enter choice : ";
cin>>choice;
switch(choice)
{case 1:cout<<"Enter item to insert: ";
cin>>item;
circular(item);
goto again;
case 2:cout<<"\nInserted item = ";
circulardisplay();cout<<"\n";
goto again;
case 3:cout<<"\nTHANK YOU";
default:break;
}
getch();
}
void circular(int item)
{temp=(node*)malloc(sizeof(node));
temp->info=item;
temp->next=start;
node* current;
if(start==NULL)
{start=temp;
temp->next=start;
}
else
{current=start;
while(current->next!=start)
{current=current->next;
}
current->next=temp;
}
}
void circulardisplay()
{current= start;
do{
cout<<current->info<<" ";
current=current->next;
}while(current!=start);
}
what happing in this program tell me in simple words
ReplyDeleteGood code. But what about insertion and deletion from different ends or middle of the circular linked list? Here is a good example for that circular linked list C++ program.
ReplyDeleteFavTutor
ReplyDeleteNice !!
https://favtutor.com/blogs/sorting-algorithms-java
Are you searching for data science projects for beginners? Here statanalytica provides 25 best-ever data science projects for beginners.
ReplyDelete