0% found this document useful (0 votes)
6 views3 pages

Queue

The document contains a C++ implementation of a circular queue with basic operations such as insertion, deletion, and display. It includes methods to check if the queue is empty or full, and handles user interaction through a menu-driven interface. There are several syntax errors and logical issues in the code that need to be corrected for proper functionality.

Uploaded by

adityajangde2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Queue

The document contains a C++ implementation of a circular queue with basic operations such as insertion, deletion, and display. It includes methods to check if the queue is empty or full, and handles user interaction through a menu-driven interface. There are several syntax errors and logical issues in the code that need to be corrected for proper functionality.

Uploaded by

adityajangde2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include<iostream.

h>
#include<conio.h>
class queue

int a[3];
int front, rear;
public:
queue()
front=rear=-1;

int isempty()
if(front==-1)
return(1);
return(0);
}
int isfull()
{
return( (front==0 && rear==2)||(front==rear+1));

void insert(int);
void deleted();
void display() ;
};
void queue :: insert(int item)

if(isful11())
cout<<"\n queue is a overflow";
return;
if (isempty())
front=0;
rear=0;
else
if (rear=2)
rear=1;
else

rear=rear+1;
a[rear]=item;
void queue: :deleted()

if(isempty() )
{
cout<<"\n queue is underflow";
}
cout<<"\n item no."<<a[front]<<"is processed";
if(front==rear)
front=-1;
rear=-1;
else
if(front==2)
front=0;
else
front=front+1;
void queue: :display()

if(front<rear)
for(int i=front;i<=rear;i++)
else cout<<"\t"<<a[i];
{
for(int i=front;i(=2;i++)
cout<<"\t"<<a[i];
for(i=0;i<=rear;i++)
cout<<"\t"<<a[i];
void main()
int ch, item=0;
queue obj;
do

clrscr() ;
1/cout<<"\n item waiting for
execution \n\n";
//obj.display();
cout<<"\n
cout<<"\n * ME NU *
cout<<"\n 1. Insert item";
cout<«"\n 2. Delete item" ;
cout<<"\n 3. Display item":
cout<<"\n 4. exit":
cout<<"\n enter your choice";
cin>>ch;
switch(ch)
case 1:if(obj.isfull());
cout<<"\n enter the job no";
cin>>item;
obj.insert (item);
break:
case 2: obj.deleted(O;
break;
case 3:if(obj. isempty())
{
cout<<"\n queue is underflow";
break;
}
else
obj.display();
break;
case 4: break;
default: cout<<"\n invalid choice";

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

You might also like