Do the following for a linkedlist based queue a Declare a st
Solution
#include<stdio.h>
#include<stdlib.h>
struct custmor
{
int id;
struct custmor* next;
}*rear, *front;
void push(int value)
{
struct custmor *temp;
temp=(struct custmor *)malloc(sizeof(struct custmor));
temp->id=value;
if (front == NULL)
{
front=temp;
front->next=NULL;
rear=front;
}
else
{
front->next=temp;
front=temp;
front->next=NULL;
}
}
void display()
{
struct custmor *var=rear;
if(var!=NULL)
{
printf(\"\ Elements are as: \");
while(var!=NULL)
{
printf(\"\\t%d\",var->id);
var=var->next;
}
printf(\"\ \");
}
else
printf(\"\ Queue is Empty\");
}
int main()
{
int i=0;
front=NULL;
printf(\" \ 1. insert to Queue\");
printf(\" \ 2. display from Queue\");
printf(\" \ 3. Exit\ \");
while(1)
{
printf(\" \ Choose Option: \");
scanf(\"%d\",&i);
switch(i)
{
case 1:
{
int value;
printf(\"\ Enter a valueber to push into Queue: \");
scanf(\"%d\",&value);
push(value);
display();
break;
}
case 2:
{
display();
break;
case 3:
{
exit(0);
}
default:
{
printf(\"\ wrong choice for operation\");
}
}
}
}
}

