Practical-8 & 9 Aim: Implement Insert and Delete Algorithms of Queue Using Array. Input
Practical-8 & 9 Aim: Implement Insert and Delete Algorithms of Queue Using Array. Input
INPUT:
#include<iostream.h>
#include<conio.h>
#define maxsize 5
#include<stdlib.h>
int front=-1,rear=-1;
int q[5];
void insert(int);
void delet();
void display();
void main()
{
int choice,item;
clrscr();
while(1)
{
cout<<"Choose any of the operation by writing their number :";
cout<<"\n1)insert\n2)delete\n3)Display\n4)Exit\n";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter element:";
cin>>item;
insert(item);
break;
case 2:
delet();
break;
case 3:
display();
case 4:
exit(0);
getch();
default:
cout<<"Invalid choice!";
break;
}
}
getch();
}
void insert(int item)
{
if(rear >= 4)
{
cout<<"Queue Overflow\n";
getch();
return;
}
rear++;
q[rear] = item;
if(front == -1)
{
front = 0;
}
}
void delet()
{
int item;
if(front == -1)
{
cout<<"Queue Underflow\n";
getch();
return;
}
item=q[front];
if(front == rear)