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"<