double link list complete//


#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node* link;
};
int main()
{
       struct node *ptr3,*temp2 ,*head=NULL,*ptr=NULL,*front=NULL,*rear=NULL,*temp=NULL,*ptr2=NULL;//pointer declaration
       int n;

       printf("circular queue program is created by mine\n\n");
       printf("===========================================================================\n");
       while(1)
       {

       printf("press the key for doing operations in our program\n");
       printf("1. enqueue\n2. dequeue\n3. view the queue\n4. exit\n");
       scanf("%d",&n);
       switch(n)
       {
case 1:

temp=(struct node*)malloc(sizeof(struct node)); //memory allocated
temp->link=NULL;
printf("enter the value in new node\n");
scanf("%d",&temp->data);

if(head==NULL)
       {
head=temp;
front=head;
rear=head;
rear->link=front;

  }
else
{
   rear=head;
   while(rear->link!=head)
   rear=rear->link;
   rear->link=temp;
   rear=temp;
   rear->link=head;


   }
break;
case 2:
if(front==NULL)
printf("queue is empty\n");
else if(front==rear)
{

    printf("deleted element is =%d",front->data);
    front=NULL;
    rear=NULL;
    head=NULL;

   }
else
{
   ptr2=front;
   printf("deleted element is =%d",ptr2->data);
   front=front->link;
   rear->link=front;
   head=front;
   ptr2->link=NULL;
   free(ptr2);
}
break;
case 3:
if(head==NULL)
printf("queue is empty\n");


else
{
     ptr3=head;
     do
     {
printf("%d\t",ptr3->data);
ptr3=ptr3->link;
}
     while(ptr3!=head);
}
break;
case 4:
exit(0);
break;
default:
printf("you have choosen wrong value\n");
break;

 }          }
 getch();
}