#include
#include
struct queue
{
int data;
struct queue *next;
}*start=NULL,*new_node,*current;
void qinsert();
void display();
void qdelete();
int front=0,rear=0;
int main()
{
int choice;
do
{
printf(“\n=========Main Menu========\n”);
printf(“0.Exit\n”);
printf(“1.Insert\n”);
printf(“2.Delete\n”);
printf(“3.Display\n”);
printf(“\nEnter you choice:”);
scanf(“%d”,&choice);
switch(choice)
{
case 0: exit;
break;
case 1: qinsert();
break;
case 2: qdelete();
break;
case 3: display();
break;
}
}while(choice);
}
void qinsert()
{
if(rear>5)
{
printf(“Queue full\n”);
}
else
{
new_node=(struct queue *)malloc(sizeof(struct queue));
printf(“Enter data:”);
scanf(“%d”,&new_node->data);
new_node->next=NULL;
if(!start)
{
start=new_node;
current=new_node;
rear++;
printf(“rear=%d\n”,rear);
}
else
{
current->next=new_node;
current=new_node;
rear++;
printf(“rear=%d\n”,rear);
}
}
}
void qdelete()
{
struct queue *temp;
if(rear==front)
{
printf(“Front=%d\nRear=%d\n”,front,rear);
printf(“Queue empty\n”);
}
else
{
temp=start->next;
start->next=NULL;
start=temp;
front++;
printf(“front is : %d\n”,front);
}
}
void display()
{
struct queue *check;
check=start;
while(check)
{
printf(“Queue:%d\n”,check->data);
check=check->next;
}
}