0% found this document useful (0 votes)
3 views2 pages

C Queue Operations Implementation

This document contains a C program that implements a queue using an array. It provides options for enqueueing, dequeueing, displaying the queue, and exiting the program. The program handles overflow and underflow conditions appropriately.

Uploaded by

engineermemer57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

C Queue Operations Implementation

This document contains a C program that implements a queue using an array. It provides options for enqueueing, dequeueing, displaying the queue, and exiting the program. The program handles overflow and underflow conditions appropriately.

Uploaded by

engineermemer57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include <stdio.

h>
# define SIZE 100
int inp_arr[SIZE];
int Rear = - 1;
int Front = - 1;
void main()
{
int ch,insert_item;
while (1)
{
printf("\[Link] Operation\n");
printf("[Link] Operation\n");
printf("[Link] the Queue\n");
printf("[Link]\n");
printf("Enter your choice of operations : ");
scanf("%d", &ch);
switch (ch)
{
case 1:
if (Rear == SIZE - 1)
printf("Overflow \n");
else
{
if (Front == - 1)

Front = 0;
printf("Element to be inserted in the Queue : ");
scanf("%d", &insert_item);
Rear = Rear + 1;
inp_arr[Rear] = insert_item;
}
break;
case 2:
if (Front == - 1 || Front > Rear)
{
printf("Underflow \n");
return ;
}
else
{
printf("Element deleted from the Queue: %d\n", inp_arr[Front]);
Front = Front + 1;
}
break;
case 3:
if (Front == - 1)
printf("Empty Queue \n");
else
{
printf("Elements in Queue: \n");
for (int i = Front; i <= Rear; i++)
printf("%d ", inp_arr[i]);
printf("\n");
}
break;
case 4:

default:
printf("Incorrect choice \n");
}
}
}

You might also like