Exp 06 DLL
Exp 06 DLL
h>
#include<stdlib.h>
float sal;
} NODE;
int count;
} HEAD;
NODE *getNode();
void main()
int ch;
head->count = 0;
head->llink = NULL;
head->rlink = NULL;
for(;;)
printf("\n\nMenu\n");
scanf("%d", &ch);
switch(ch)
case 1:
insfront(head);
break;
case 2:
insrear(head);
break;
case 3:
if(head->rlink == NULL)
printf("List Empty");
else
delfront(head);
break;
case 4:
if(head->rlink == NULL)
printf("List Empty");
else
delrear(head);
break;
case 5:
if(head->rlink == NULL)
printf("List Empty");
else
display(head);
break;
case 6:
exit(0);
NODE *getNode()
if(temp == NULL)
printf("No Memory\n");
exit(0);
return temp;
if(next != NULL)
next->llink = new;
new->rlink = next;
head->rlink = new;
(head->count)++;
}
void insrear(HEAD *head)
(head->count)++;
new->rlink = NULL;
if(head->rlink == NULL)
head->rlink = new;
return;
temp = head->rlink;
while(temp->rlink != NULL)
temp = temp->rlink;
temp->rlink = new;
new->llink = temp;
head->rlink = temp->rlink;
free(temp);
(head->count)--;
}
void delrear(HEAD *head)
if(present->rlink == NULL)
head->rlink = NULL;
else
while(present->rlink != NULL)
previous = present;
present = present->rlink;
previous->rlink = NULL;
(head->count)--;
free(present);
printf("SSN\tName\tDepartment\tDesignation\tSalary\t\tPhNo\n");
while(temp != NULL)
{
printf("%s\t%s\t%s\t\t%s\t\t%f\t%ld\n", (temp->ssn), (temp->name), (temp-
>department), (temp->designation), (temp->sal), (temp->phno));
temp = temp->rlink;