#include<conio.h>
#include<stdio.h>
#define max 10
struct qtype{int front;int rear;int ele[max];};

int isqempty(struct qtype q)
{
 return(q.rear<q.front);
}

int isqfull(struct qtype q)
{
 return(q.rear==max-1);
}

void makeempty(struct qtype *q)
{
 q->rear=-1;
 q->front=0;
 printf("QUEUE IS MADE EMPTY:");
}

void addq(struct qtype *q,int x)
{
 q->ele[++q->rear]=x;
}

int delq(struct qtype *q)
{int x=q->ele[q->front];
 if(q->front==q->rear) makeempty(q);
 else q->front++;
 return x;
}

void disp(struct qtype q)
{
 int i;
 for(i=q.front;i<=q.rear;i++)  printf("\t %d",q.ele[i]);
}


void main()
{
 struct qtype q={0,-1,{0}};
 int n,x;
 while(1)
 {
  clrscr();
  printf("1.ADD\n 2.DELETE\n 3.LIST\n 4.MAKE-EMPTY\n 5.EXIT\n");
  printf("ENTER UR CHOICE 1/2/3/4/5\n");
  scanf("%d",&n);
  if(n==5) break;
  switch(n)
  {
   case 1:
	  if(!isqfull(q))
	  {
	   printf("ENTER THE NUMBER TO BE ADDED:");
	   scanf("%d",&x);
	   addq(&q,x);
	  }
	  else printf("QUEUE IS OVERFLOW:");
	  break;
   case 2:
	  if(isqempty(q))
	   printf("\n UNDERFLOW");
	  else printf("DELETED ELEMENT IS %d",delq(&q));
	  break;
   case 3:
	  if(isqempty(q))    printf("\n UNDERFLOW");
	  else   disp(q);
	  break;
   case 4:
	  makeempty(&q);
	  break;
   default: printf("\nINVALID OPTION");
   }
   getch();
 }
 getch();
}

