#include<stdio.h>
#include<stdlib.h>
int flag=0;
struct node
{
int val;
struct node*next;
}*front=NULL,*rear=NULL,*start=NULL;
int count=0;
int get_choice(int *);
int create_node();
int enqueue();
int dequeue();
int display();
int main()
{
int choice=1;
while(choice)
{
printf(“\n+++++++++MENU+++++++++\n”);
printf(“1.CREATE NODE\n”);
printf(“2.INSERT\n”);
printf(“3.DELETE\n”);
printf(“4.DISPLAY\n”);
printf(“0.EXIT\n”);
printf(“enter your choice”);
scanf(“%d”,&choice);
get_choice(&choice);
}}
int get_choice(int *choice)
{
switch(*choice)
{
case 1:create_node();break;
case 2:enqueue();break;
case 3:dequeue();break;
case 4:display();break;
case 0:exit(0);
}}
int create_node()
{
if(flag==0)
{
printf(“queue created\n”);
flag++;
}
else if(flag>=1)
{
printf(“queue already created\n”);
}
}
int enqueue()
{
struct node*temp;
temp=(struct node*)malloc(10*sizeof(struct node*));
if(flag==0)
{
printf(“create a queue first\n”);
return 0;
}
else if(flag==1)
{
printf(“enter the values\n”);
scanf(“%d”,&(temp->val));
temp->next=NULL;
start=rear=temp;
}
if(flag>1)
{
printf(“enter the values!\n”);
scanf(“%d”,&(temp->val));
temp->next=NULL;
rear->next=temp;
rear=rear->next;
}
if(flag>5)
{
printf(“queue is full\n”);
return 0;
}
flag++;
display();
}
int dequeue()
{
struct node*temp,*temp1;
{
if(flag==0)
printf(“create a queue first\n”);
else if(flag==1)
{
printf(“queue is empty\n`”);
}
if(!front )
{
temp=start;
front=start->next;
printf(“%d is popped\n”,temp->val);
free(temp);
}
else if(front)
{
temp=front;
front=front->next;
printf(“%d is popped\n”,temp->val);
free(temp);
printf(“\n%d”,flag);
flag–;
}
display();
}}
int display()
{
struct node*temp;
if(flag==0)
{
printf(“nothing to display\n”);
}
else if(flag>=1)
{
if(!front)
{
temp=start;
}
else
{
temp=front;
}
while(temp)
{
printf(” %d–”,temp->val);
temp = temp->next;
}
}}