int i, rear, front, item, s[10];
void insert ( int item, int s[ ]);
void del ( int s[ ]);
void display ( int s[ ]);
void main( )
{
int ch;
clrscr( );
front = 0;
rear = -1;
do
{
printf ( “\n\n1. Insertion \n2.Deletion \n3.Exit\n );
printf ( “\nEnter your choice: \n”);
{
case 1:
printf(“\n \t \t "Insertion \"\n\n");
if (rear >= 9)
{
printf ("\n\t\t"Queue is full\"\n");
}
else
{
printf ("Enter an element\n");
scanf("%d", &item );
insert (item, s)
}
display (s);
break;
case 2:
printf ("\n\t\t\"Deletion \"\n");
if ( front > rear)
{
printf ("\n \t\ "Queue is empty\"\n");
}
else
{
del(s);
}
display (s);
break;
}
}while (ch!=3 );
getch( );
}
void insert (int item, int s[ ] )
{
rear = rear + 1;
s[rear] = item;
}
void del ( int s[ ] )
{
item = s[front];
front = front +1;
printf ("\n \t \t \ "Deleted element is %d \"\n \n", item);
}
void display (int s[ ] )
{
printf (" \n ");
for ( i = front; i<= rear; i++)
{
printf ("\t %d", s[i]);
}
}
SAMPLE INPUT OUTPUT:
1.INSERTION
2.DELETION
3.EXIT
ENTER YOUR CHOICE: 1
INSERTION
ENTER AN ELEMENT: 11
11
1.INSERTION
2.DELETION
3.EXIT
ENTER YOUR CHOICE: 1
INSERTION
ENTER AN ELEMENT: 12
12
1.INSERTION
2.DELETION
3.EXIT
ENTER YOUR CHOICE: 1
INSERTION
ENTER AN ELEMENT: 13
11 12 13
1.INSERTION
2.DELETION
3.EXIT
ENTER YOUR CHOICE: 2
DELETION
DELETED ELEMENT IS 11
13
1.INSERTION
2.DELETION
3.EXIT
ENTER YOUR CHOICE: 2
DELETION
DELETED ELEMENT IS 12
13
1.INSERTION
2.DELETION
3.EXIT
ENTER YOUR CHOICE: 2
DELETION
QUEUE IS EMPTY
1.INSERTION
2.DELETION
3.EXIT
ENTER YOUR CHOICE: 3