QUEUE





IMPLEMENTATION OF ADT - QUEUE

SOURCE CODE

#include “iostream.h”
#include “conio.h”
#include

class queue
{
public:
int queue1[5],rear,front;
void display();

queue()
{
rear=-1;
front=-1;
}

void insert(int x)
{
if(rear>4)
{
cout << "Queue Overflow"; front=rear=-1; return; } queue1[++rear]=x; cout << "Inserted " << front="="rear)" rear="="front)" i="front+1;i<="rear;i++)">> ch;
switch(ch)
{
case 1:
cout << "Enter The Element : "; cin >> ch;
qu.insert(ch);
break;
case 2:
qu.delet();
break;
case 3:
qu.display();
break;
case 4:
exit(0);
}
}
}



OUTPUT


MAIN MENU
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter Your Choice : 1
Enter The Element : 1
Inserted 1
MAIN MENU
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter Your Choice : 1
Enter The Element : 2
Inserted 2
MAIN MENU
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter Your Choice : 1
Enter The Element : 3
Inserted 3
MAIN MENU
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter Your Choice : 3
1 2 3
MAIN MENU
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter Your Choice : 2
Deleted 1
MAIN MENU
1.INSERT
2.DELETE
3.DISPLAY
4.EXIT
Enter Your Choice : 4