#include <iostream>
#include <conio>
void add(int,int*,int*,int*);
int delet(int*,int*,int*,int*);
void print(int*);
int queue[10],item;
int main()
{
int rear=0,front=0,remove;
char ch=100;
while(ch!='4'&&ch!=27)
{
clrscr();
cout<<"What do you want to do?\n\n";
cout<<"1-Add\n2-Delete\n3-Print\n4-Exit\n\n";
cout<<"What is your selection :";
ch=getch();
switch(ch)
{
case'1':
clrscr();
cout<<"Please eneter a number :";
cin>>item;
add(item,&rear,&front,queue);
break;
case'2':
clrscr();
remove=delet(&item,&rear,&front,queue);
if(remove!=0)
cout<<"Deleted number is :"<<remove;
queue[front]=0;
getch();
break;
case'3':
clrscr();
cout<<"The queue is :";
print(queue);
getch();
break;
case'4':
return 0;
}
}
getch();
return 0;
}
//***********************************************
void add(int item,int*r,int*f,int*q)
{
if(*r==9)
*r=0;
else
*r+=1;
if(*r==*f)
{
cout<<"Queue is full";
*r-=1;
getch();
}
else
q[*r]=item;
}
//***********************************************
int delet(int*item,int*r,int*f,int*q)
{
if(*f==*r)
{
cout<<"Queue is empety";
return 0;
}
else
{
if(*f==9)
*f=0;
else
*f+=1;
}
return q[*f];
}
//***********************************************
void print(int *q)
{
cout<<"\n";
for(int i=0;i<10;i++)
{
cout<<q[i];
if(i<9)cout<<",";
}
}