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

Queue

The document contains a C++ implementation of a queue data structure using an array with a maximum size of 10. It includes methods for checking if the queue is empty or full, adding elements (enqueue), removing elements (delqueue), and displaying the current elements in the queue. The main function provides a user interface for interacting with the queue through a menu-driven approach.

Uploaded by

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

Queue

The document contains a C++ implementation of a queue data structure using an array with a maximum size of 10. It includes methods for checking if the queue is empty or full, adding elements (enqueue), removing elements (delqueue), and displaying the current elements in the queue. The main function provides a user interface for interacting with the queue through a menu-driven approach.

Uploaded by

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

#include <iostream>

#define MAX 10

using namespace std;

struct queue

{ int data[MAX];

int front,rear;

};

class Queue

{ struct queue q;

public:

Queue(){[Link]=[Link]=-1;}

int isempty();

int isfull();

void enqueue(int);

int delqueue();

void display();

};

int Queue::isempty()

return([Link]==[Link])?1:0;

int Queue::isfull()

{ return([Link]==MAX-1)?1:0;}

void Queue::enqueue(int x)

{[Link][++[Link]]=x;}

int Queue::delqueue()

{return [Link][++[Link]];}

void Queue::display()

{ int i;

cout<<"\n";

for(i=[Link]+1;i<=[Link];i++)
cout<<[Link][i]<<" ";

int main()

{ Queue obj;

int ch,x;

do{ cout<<"\n [Link] Job\n [Link] Job\n [Link]\n [Link]\n Enter your choice : ";

cin>>ch;

switch(ch)

{ case 1: if (![Link]())

{ cout<<"\n Enter data : \n";

cin>>x;

[Link](x);

cout<<endl;

else

cout<< "Queue is overflow!!!\n\n";

break;

case 2: if(![Link]())

cout<<"\n Deleted Element = "<<[Link]()<<endl;

else

{ cout<<"\n Queue is underflow!!!\n\n"; }

cout<<"\nRemaining Jobs : \n";

[Link]();

break;

case 3: if (![Link]())

{ cout<<"\n Queue contains : \n";

[Link]();

else

cout<<"\n Queue is empty!!!\n\n";

break;
case 4: cout<<"\n Exiting Program.....";

}while(ch!=4);

return 0;

You might also like