#include<iostream>
using namespace std;
struct node{
int data;
node* next;
};
node* front=NULL;
node* rear=NULL;
void enqueue(int value)
{
node* new_node=new node;
new_node-> data=value;
new_node->next=NULL;
if(front==NULL&&rear==NULL)
{
front=rear=new_node;
}
else
{
rear->next=new_node;
rear=new_node;
}
}
int dequeue()
{
int value;
if(rear=NULL)
{
cout << "Queue us empty " ;
}
else if(front==rear)
{
node* first_node=front;
front=rear=NULL;
delete first_node;
return value;
}
else
{
node* first_node=front;
front =front->next;
value =first_node->data;
delete first_node;
return value;
}
}
void display ()
{
node* current;
if(front==NULL)
{
cout << "Queue is empty " ;
}
else
{
current =front;
while(current!=NULL)
{
cout << current->data<<"\t";
current=current->next;
}
}
}
int main()
{
enqueue(5);
enqueue(10);
enqueue(15);
enqueue(20);
enqueue(25);
display();
cout << endl;
cout <<dequeue();
cout << endl;
display();
return 0;
}