You are on page 1of 2

#include<iostream.h> #include<conio.

h> void main() { int item,ch,a[10],front,rear,n; clrscr(); front=rear=0; cout<<"\n\t\t QUEUE"; cout<<"\n Enter the Queue size:"; cin>>n; do { cout<<"\n\t\t 1.Insert\n\t\t 2.Delete\n\t\t 3.Display\n\t\t 4.Exit\n\t\t En ter ur choice: "; cin>>ch; switch(ch) { case 1: if(rear>=n) cout<<"\nQueue is full"; else { cout<<"\n Enter the element:"; cin>>item; rear=rear+1; a[rear]=item; cout<<"\n The element is inserted"; } break; case 2: if(rear==0 || front==rear) cout<<"\n Queue is empty"; else { front=front+1; item=a[front]; cout<<"\n The deleted element:"<<item; } break; case 3: if(rear==0 || front==rear) cout<<"\n Queue is empty"; else { cout<<"\n Elements of the Queue:\n"; for(item=front;item<=rear;item++) cout<<"\t"<<a[item]; } break; case 4: cout<<"\n End of operation"; break; default: cout<<"\n Invalid choice"; break;

} }while(ch!=4); getch(); }

You might also like