Program8_DLL
Program8_DLL
Develop a menu driven Program in C for the following operations on Doubly LinkedList (DLL)
of Employee Data with the fields: SSN, Name, Dept, Designation,
Sal, PhNo
a. Create a DLL of N Employees Data by using end insertion.
b. Display the status of DLL and count the number of nodes in it
c. Perform Insertion and Deletion at End of DLL
d. Perform Insertion and Deletion at Front of DLL
e. Demonstrate how this DLL can be used as Double Ended Queue.
f. Exit
#include<stdio.h>
#include<conio.h>
void insertfront();
void deletefront();
void insertend();
void deleteend();
void display();
void deqdemo();
struct node
char ssn[25],name[25],dept[10],designation[25];
};
int count=0;
void main()
int ch,n,i;
clrscr();
printf("2.display\n");
printf("3.InserAtfront\n");
printf("4.DeleteAtEnd\n");
printf("5.DeleteAtFront\n");
printf("6.deqdemo\n");
printf("7.exit\n");
while(1)
scanf("%d",&ch);
switch(ch)
case 1:
insertend();
break;
case 2: display();
break;
case 3: insertfront();
break;
case 4: deleteend();
break;
case 5:deletefront();
break;
case 6:deqdemo();
break;
case 7: exit(0);
break;
}
}
void insertend()
if(temp==NULL)
exit(0);
temp->next=NULL;
temp->prev=NULL;
count++;
if(head==NULL)
head=tail=temp;
else
tail->next=temp;
temp->prev=tail;
tail=temp;
}
}
void insertfront()
if(temp==NULL)
exit(0);
temp->prev=NULL;
count++;
if(tail==NULL)
temp->next=NULL;
head=tail=temp;
else
head->prev=temp;
temp->next=head;
head=temp;
}
void deletefront()
if(head==NULL)
printf("list is empty\n");
return;
else
temp=head;
head=head->next;
head->prev=NULL;
count--;
free(temp);
void deleteend()
if(tail==NULL)
printf("list is empty\n");
return;
else
temp=tail;
temp->prev->next=NULL;
tail=tail->prev;
printf("\nThe Employee node with ssn %s is deleted",temp->ssn);
free(temp);
count--;
void display()
int num=1;
if(head==NULL)
printf("list is empty\n");
return;
else
while(temp!=NULL)
temp=temp->next;
num++;
void deqdemo()
{
int ch;
while(1)
scanf("%d", &ch);
switch(ch)
case 1: insertfront();
break;
case 2: insertend();
break;
case 3: deleteend();
break;
case 4:deletefront();
break;
case 5:display();
break;
case 6:exit(0);
default: return;