Practical 6
Practical 6
void insert()
{
int item;
if (Rear == 5 - 1)
printf("Overflow \n");
else
{
if (Front == - 1)
Front = 0;
printf("Element to be inserted in the Queue\n : ");
scanf("%d", &item);
Rear = Rear + 1;
queue[Rear] = item;
}
}
void delete()
{
if (Front == - 1 || Front > Rear)
{
printf("Underflow \n");
return ;
}
else
{
printf("Element deleted from the Queue: %d\n", queue[Front]);
Front = Front + 1;
}
}
void show()
{
if (Front == - 1)
printf("Empty Queue \n");
else
{
printf("Queue: \n");
for (int i = Front; i <= Rear; i++)
printf("%d ", queue[i]);
printf("\n");
}
}
Output:
1.Insert Operation
2.Delete Operation
3.Display the Queue
4.Exit
Enter your choice of operations : 1
Element to be inserted in the Queue
: 10
1.Insert Operation
2.Delete Operation
3.Display the Queue
4.Exit
Enter your choice of operations : 1
Element to be inserted in the Queue
: 20
1.Insert Operation
2.Delete Operation
3.Display the Queue
4.Exit
Enter your choice of operations : 1
Element to be inserted in the Queue
: 30
1.Insert Operation
2.Delete Operation
3.Display the Queue
4.Exit
Enter your choice of operations : 3
Queue:
10 20 30
1.Insert Operation
2.Delete Operation
3.Display the Queue
4.Exit
Enter your choice of operations : 2
Element deleted from the Queue: 10
1.Insert Operation
2.Delete Operation
3.Display the Queue
4.Exit
Enter your choice of operations : 3
Queue:
20 30