#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int data;
}node;
struct node *next;
}LL;
typedef struct
{
node *newrec,*p;
node *start;
void enqueue(LL *l,int ele)
{
if(l->start==NULL)
newrec=(node*)malloc(sizeof(node));
newrec->data=ele;
{
while(p->next!=NULL)
l->start=newrec;
newrec->next=NULL;
}
else
{
int dequeue(LL *l)
p=l->start;
{
p=p->next;
}
p->next=newrec;
newrec->next=NULL;
max=l->start->data;
}
}
int max;
{
node *p,*q,*i;
if(l->start==NULL)
{
return -1;
}
p=l->start;
else
{
max=i->data;
q=l->start;
i=l->start->next;
while(i!=NULL)
if(i->data>max)
{
{
p=i;
return q->data;
}
i=i->next;
}
if(l->start->data==max)
{
l->start=q->next;
void display(LL *l)
q->next=NULL;
}
while(q->next!=p)
{
q=q->next;
}
return max;
q->next=p->next;
}
}
{
p=l->start;
node *p;
if(l->start==NULL)
{
printf("The linked list is empty\n");
return;
}
else
int main()
{
while(p!=NULL)
{
printf("%d \t",p->data);
p=p->next;
}
printf("Enter the choice\n");
printf("\n");
}
}
{
LL l;
l.start=NULL;
int ch,ele;
printf("Menu\n1.Enqueue\n2.Dequeue\n3.Display\n4.Exit");
while(1)
{
case 1 : printf("Enter the element to insert\n");
scanf("%d",&ch);
if(ch==4)
{
switch(ch)
break;
}
{
enqueue(&l,ele);
scanf("%d",&ele);
else
display(&l);
break;
case 2 : if(l.start==NULL)
printf("The linked list is empty\n");
{
case 3 : display(&l);
ele=dequeue(&l);
printf("%d is the deleted element\n",ele);
display(&l);
}
}
break;
break;
default : printf("The choice is invalid\n");
}
}
return 0;