8 DLL
8 DLL
Develop a menu driven Program in C for the following operations on Doubly Linked List
(DLL) of Employee Data with the fields: SSN, Name, Dept, Designation,
Sal, PhNo
f. Exit
*/
// Header files
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include<ctype.h>
#define MAX 30
struct List
int SSN;
char Name[MAX];
char Dept[MAX];
char Designation[MAX];
float Sal;
char PhNo[MAX];
struct List *prev;
};
#define MALLOC(p,s,t)\
p=(t)malloc(s);\
if(p==NULL){ \
printf("Insufficient Memory\n"); \
exit; \
//prototypes
void ReadData();
int main()
NODE fi;
fi= NULL;
done = 0;
while (!done)
scanf("%d", &choice);
switch (choice)
scanf("%d", &n);
fi = Create(fi, n);
break;
case 2: ReadData();
fi = InsFront(fi);
break;
case 3: ReadData();
fi = InsRear(fi);
break;
break;
case 7: done=1;
break;
break;
return 0;
void ReadData()
scanf("%d", &ssn);
scanf("%s",name);
scanf("%s",dept);
scanf("%s",desig);
scanf("%f", &salary);
scanf("%s",phone); }
int i; NODE q;
if (first == NULL)
ReadData();
first = InsFront(first);
return first;
else
NODE q;
q->SSN = ssn;
strcpy(q->Dept, dept);
strcpy(q->Designation, desig);
q->Sal = salary;
strcpy(q->PhNo, phone);
q->prev = NULL;
q->next = first;
if(first != NULL)
first->prev = q;
return q;
NODE q, cur;
cur = first;
while(cur->next != NULL)
cur = cur->next;
q->SSN = ssn;
strcpy(q->Dept, dept);
strcpy(q->Designation, desig);
q->Sal = salary;
strcpy(q->PhNo, phone);
q->next = NULL;
cur->next = q;
q->prev = cur;
return first;
{ NODE cur;
if(first == NULL)
return NULL;
else
cur=first;
first = first->next;
first->prev = NULL;
free(cur);
return first;
if(first == NULL)
return NULL;
if(first->next == NULL)
return first=NULL;
else
while(cur->next != NULL)
cur = cur->next;
cur->prev->next = NULL;}
free(cur);
return first;
int count=0;
if(first == NULL)
printf("\nList is Empty\n");
else
while (first)
first = first->next;
count++;
printf("Count of Nodes=%d\n",count);
/* OUTPUT
1.Create
Enter Choice: 4
Enter Choice: 5
1.Create
Enter Choice: 6
List is Empty
Count of Nodes=0
1.Create
Enter Choice: 1
1.Create
Enter Choice: 6
Count of Nodes=2
1.Create
Enter Choice: 2
1.Create
Count of Nodes=3
1.Create
Enter Choice: 3
1.Create
Enter Choice: 6
Count of Nodes=4
1.Create
2.InsFront 3.InsRear 4.Delete Front
Enter Choice: 4
1.Create
Enter Choice: 6
Count of Nodes=3
1.Create
Enter Choice: 5
1.Create
Enter Choice: 6
Count of Nodes=2
1.Create
1.Create
Enter Choice: 4
*/