#include<conio.h>
#include<alloc.h>
typedef struct dll
{
int data; struct dll *next; struct dll *prev;
}node;
//struct dll *head=NULL; node *getnode()
{
node *temp; temp=(node *)malloc(sizeof(node)); temp->next=NULL; temp->prev=NULL; return temp;
}
node *creation()
{
node *temp,*new1,*head; int f=1; char c;
do { new1=getnode(); printf("\n\nEnter the data.\n\n"); scanf("%d",&new1->data);
if(f==1) { head=new1; temp=head; f=0; }
else { temp->next=new1; new1->prev=temp; temp=new1; } printf("\n\nDo you want to continue with creation.\n\n"); c=getche(); }while(c=='y'||c=='Y'); return head;
}
void display(node *head)
{
node *temp; temp=head; printf("\n\nThe list is...\n\n"); while(temp!=NULL) { printf("%d\n",temp->data); temp=temp->next; }
}
node *insertion(node *head)
{
node *new1,*temp; int c,value; char ch; do { new1=getnode(); printf("\n\nEnter the data to be insered.\n\n"); scanf("%d",&new1->data); printf("\n\nEnter your place of insertion.\n\n"); printf("\n1.Head.\n2.Intermediate.\n3.Tail.\n"); scanf("%d",&c); switch(c) { case 1: temp=head; new1->next=temp; temp->prev=new1; head=new1; break; case 2: temp=head; printf("\n\nEnter the value after which the insertion has to take place.\n\n"); scanf("%d",&value); while(temp->data!=value) { temp=temp->next; } temp->next->prev=new1; new1->next=temp->next; temp->next=new1; new1->prev=temp; break; case 3: temp=head; while(temp->next!=NULL) { temp=temp->next; } temp->next=new1; new1->next=NULL; new1->prev=temp; break; } printf("\n\nDo you want to continue with insertion.\n\n"); ch=getche(); }while(ch=='y'||ch=='Y'); return