#include<stdio.h> void enq(); void deq(); void display(); main() { int n; printf("\tMENU\n1.ENQUEUE\n2.DEQUEUE\n3.DISPLAY\n4.

EXIT\n"); do { printf("\nEnter your choice\n"); scanf("%d",&n); switch(n) { case 1: enq(); break; case 2: deq(); break; case 3: display(); break; case 4: break; default: printf("Invalid choice\n"); break; } } while(n!=4); } typedef struct node { int data; struct node *link; }n; n *front=NULL; n *rear=NULL; void enq() { int item; n *temp; printf("Enter the item\n"); scanf("%d",&item); temp=(n*)malloc(sizeof(n)); temp->data=item; temp->link=NULL; if(rear==NULL) { front=temp; rear=temp; } else { rear->link=temp; rear=temp; }

item). } if(front==rear) { front=NULL. } else front=front->link. } } } . printf("The elements of the queue are :"). if(front==NULL) printf("Queue is empty\n"). rear=NULL. else { item=front->data. ptr=ptr->link.ptr->data). else { ptr=front. if(front==NULL) printf("Queue is empty\n"). printf("The element deleted = %d\n". while(ptr!=NULL) { printf("%d\t". } void display() { n *ptr.} void deq() { int item.

Sign up to vote on this title
UsefulNot useful