Nov
28
2008
28
2008
C++ Program to implement a QUEUE using linked list
C++ Program to implement a QUEUE using linked list.
/************************************************************** Author: Arun Vishnu M V Web: www.arunmvishnu.com Description: C++ Program to implement a QUEUE using linked list. ***************************************************************/ #include<conio.h> #include<iostream.h> #include<process.h> #include<malloc.h> // Creating a NODE Structure struct node { int data; struct node *next; }; // Creating a class QUEUE class queue { struct node *frnt,*rear; public: queue() // constructure { frnt=rear=NULL; } void insert(); // to insert an element void del(); // to delete an element void show(); // to show the stack }; // Insertion void queue::insert() { int value; struct node *ptr; cout<<"\nInsertion\n"; cout<<"Enter a number to insert: "; cin>>value; ptr=new node; ptr->data=value; ptr->next=NULL; if(frnt==NULL) frnt=ptr; else rear->next=ptr; rear=ptr; cout<<"\nNew item is inserted to the Queue!!!"; getch(); } // Deletion void queue::del() { if(frnt==NULL) { cout<<"\nQueue is empty!!"; getch(); return; } struct node *temp; temp=frnt; frnt=frnt->next; cout<<"\nDeletion Operation........\nDeleted value is "<<temp->data; delete temp; getch(); } // Show Queue void queue::show() { struct node *ptr1=frnt; if(frnt==NULL) { cout<<"The Queue is empty!!"; getch(); return; } cout<<"\nThe Queue is\n"; while(ptr1!=NULL) { cout<<ptr1->data<<" ->"; ptr1=ptr1->next; } cout<<"END"; getch(); } // Main function int main() { clrscr(); queue q; int choice; while(1) { cout<<"\n-----------------------------------------------------------"; cout<<"\n\t\tQUEUE USING LINKED LIST\n\n"; cout<<"1:INSERTION\n2:DELETION\n3:DISPLAY QUEUE\n4:EXIT"; cout<<"\nEnter your choice(1-4): "; cin>>choice; switch(choice) { case 1: q.insert(); break; case 2: q.del(); break; case 3: q.show(); break; case 4: exit(0); break; default: cout<<"Please enter correct choice(1-4)!!"; getch(); break; } } return 0; } //---------------------- END--------------------
Related Posts
Latest Posts
- What is the real meaning of Facebook “Like”?
- Wish you and your family a very Happy and Prosperous New Year 2012!
- Import Orkut’s albums to Google+
- Download 100 Paid Android Apps(Like Fruit Ninja HD, BW, Smart Office etc. )For Free
- List Of Samsung Devices Getting Official Android 4.x Ice Cream Sandwich Update
- How to Restrict Facebook friends using lists
- How to clean iPhone/iPad/iPod backup files
- Apple’s Siri On iPhone 4S vs Microsoft’s Tellme On Windows Phone
- Your Facebook account hacked? Here’s how to fix it
- Indian Railway Enabled VRM System to travel without the printout of e-ticket
Tags
apple
c and cpp
Cheats
download
downloads
Entertainment
error
Film
friendship
Fun
gadgets
Games
gmail
google
greetings
india
Internet
iphone
java script
linux
love
mac
microsoft
mobile
News
office
onam
Personal
photos
Programming
review
Security
software
source code
technology
Tips & Tricks
video
videos
virus
web
web development
windows
windows 7
worm
yahoo
Recent Comments
- salman on C++ Program Program for Binary Search.
- Mithun on C++ Program to implement a QUEUE using linked list
- The Tamale Chica Chronicles has moved! | Tamale Chica Chronicles on Get redirection script
- Aparajita Chaudhuri on C++ Program implement a stack using an array
- Harta on Disable Adobe CS4 Activation Check

An article by
The best code.
It compiled without any bug
Been searching for one of these for a while and this IS the best one.
HELLO SIR.THIS IS THARUN.
SIR I WANT TO KNOW MORE PROGRAMMES ON C .CAN U PLEASE SEND ME UR PERSONNAL WEBSITE ADDRESS PLEASE.
thank a loooooooooooooooooooooot. my practs start form 1st and it was helpful to find an error free program…
Once u make a sample program can u please make it in a simple and short.
Thank’s..
thank u so much for this program. i am really impressed for this program..
well, its gud code
literally a life saver, keep posting such a nice literatures. Thanks
Thanks.. It has help me… Thank you very much..
seriously the best code for linked list …..really helped me
awsome work dude,really helped me a lot.