



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




#include
#include
if (front==-1) front=0; rear++; Queue[rear]=item; } } int dequeue() { if(isEmpty()) { cout<<"Queue Underflow \n"; return - 1; } else { int item=Queue[front]; front++; return item; } } void traverse() { if(isEmpty()) cout<<"Queue is Empty \n"; else { for(int i=front;i<=rear;i++) cout<<Queue[i]<<" "; } cout<<endl; } void main() { int ch,item; front=rear=-1; cout<<"Enter Queue Size"; cin>>size; Queue=new int [size]; while(true) { cout<<"***************************************\n"; cout<<"1) Insert element to Queue \n"; cout<<"2) Delete element from Queue \n"; cout<<"3) Display all the elements of queue \n"; cout<<"4) Exit \n"; cout<<"***************************************\n"; cin>>ch; switch (ch) { case 1 : cout<<"Enter the item:"; cin>>item; enqueue(item); break; case 2 : cout<<dequeue()<<" Deleted from the Queue \n"; break;