diff --git a/C++/Program_25/Queues_Using_Linked_Lists.cpp b/C++/Program_25/Queues_Using_Linked_Lists.cpp new file mode 100644 index 00000000..65cbca63 --- /dev/null +++ b/C++/Program_25/Queues_Using_Linked_Lists.cpp @@ -0,0 +1,82 @@ +//Queues Using Linked List +#include +using namespace std; + +class node{ + public: + int data; + node *link; +}*front=NULL,*rear=NULL; + +void enqueue(int x){ + node *t; + t = new node; + if(t==NULL) + cout<<"Queue is Full"<data = x; + t->link = NULL; + } + if(front==NULL){ + front = rear = t; + } + else{ + rear->link=t; + rear = t; + } +} + +int dequeue(){ + node *p; + int x = -1; + if(front==NULL) + cout<<"Queue is Empty!"<link; + x = p->data; + delete p; + } + return x; +} + +void display(){ + node *p=front; + while(p){ + cout<data<<" "; + p = p->link; + } + cout<>c; + switch (c) + { + case '1': + cout<<"Enter the element : "; + cin>>x; + enqueue(x); + break; + case '2': + x=dequeue(); + if(x!=-1) + cout<<"Deleted element is "<