#include<stdio.
h>
#include<conio.h>
void inq();
void deq();
void display();
struct node // CREATING A NODE
{
int data;
struct node *link;
}*front=NULL,*rear=NULL;
int item;
void main()
{
int n;
clrscr();
printf("\tMENU\[Link]\[Link]\[Link]\[Link]\n");
do
{
printf("\nEnter your choice\n");
scanf("%d",&n);
switch(n)
{
case 1:
inq();
display();
break;
case 2:
deq();
display();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf("Invalid choice\n");
break;
}
}
while(n<=4);
getch();
}
void inq() // PERFORMING ENQUEUE OPERATION
{
struct node *temp;
printf("Enter the item\n");
scanf("%d",&item);
temp=(struct node*)malloc(sizeof(struct node));
temp->data=item;
temp->link=NULL;
if(rear==NULL)
{
}
else
{
}
}
front=temp;
rear=temp;
rear->link=temp;
rear=temp;
void deq() // PERFORMING DEQUEUE OPERATION
{
int item;
if(front==NULL)
{
}
else
{
}
printf("Queue is empty\n");
item=front->data;
printf("The element deleted = %d\n",item);
if(front==rear)
{
}
else
{
}
}
front=NULL;
rear=NULL;
front=front->link;
void display() // PERFORMING DISPLAY OPERATION
{
struct node *ptr;
if(front==NULL)
{
}
else
{
printf("Queue is empty\n");
ptr=front;
printf("The elements of the queue are :\n");
while(ptr!=NULL)
{
printf("%d\t",ptr->data);
ptr=ptr->link
}
}
}
Output:
OUTPUT:
MENU
[Link]
[Link]
[Link]
[Link]
Enter your choice:
1
Enter the item:
20
The elements of the queue are:
20
Enter your choice:
1
Enter the item:
30
The elements of the queue are:
20
30
Enter your choice: