From de0156a12b1138edb3ba0644754fa00af335d88e Mon Sep 17 00:00:00 2001 From: FINDINGSOM <50260279+FINDINGSOM@users.noreply.github.com> Date: Wed, 7 Oct 2020 21:24:19 +0530 Subject: [PATCH] Create QueueUsingLinkedlist.c --- QueueUsingLinkedlist.c | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 QueueUsingLinkedlist.c diff --git a/QueueUsingLinkedlist.c b/QueueUsingLinkedlist.c new file mode 100644 index 0000000..36d3dda --- /dev/null +++ b/QueueUsingLinkedlist.c @@ -0,0 +1,81 @@ +#include +using namespace std; +struct node { + int data; + struct node *next; +}; +struct node* front = NULL; +struct node* rear = NULL; +struct node* temp; +void Insert() { + int val; + cout<<"Insert the element in queue : "<>val; + if (rear == NULL) { + rear = (struct node *)malloc(sizeof(struct node)); + rear->next = NULL; + rear->data = val; + front = rear; + } else { + temp=(struct node *)malloc(sizeof(struct node)); + rear->next = temp; + temp->data = val; + temp->next = NULL; + rear = temp; + } +} +void Delete() { + temp = front; + if (front == NULL) { + cout<<"Underflow"<next != NULL) { + temp = temp->next; + cout<<"Element deleted from queue is : "<data<data<data<<" "; + temp = temp->next; + } + cout<>ch; + switch (ch) { + case 1: Insert(); + break; + case 2: Delete(); + break; + case 3: Display(); + break; + case 4: cout<<"Exit"<