0% found this document useful (0 votes)
2 views

Program8_DLL

The document outlines a C program for managing a Doubly Linked List (DLL) of employee data, including operations such as creation, insertion, deletion, and display of employee nodes. It provides a menu-driven interface for users to perform various operations on the DLL, such as inserting and deleting nodes at both ends and demonstrating the DLL as a double-ended queue. The program includes functions for each operation and maintains a count of the nodes in the list.

Uploaded by

chavanakshay1812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Program8_DLL

The document outlines a C program for managing a Doubly Linked List (DLL) of employee data, including operations such as creation, insertion, deletion, and display of employee nodes. It provides a menu-driven interface for users to perform various operations on the DLL, such as inserting and deleting nodes at both ends and demonstrating the DLL as a double-ended queue. The program includes functions for each operation and maintains a count of the nodes in the list.

Uploaded by

chavanakshay1812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

8.

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];

long int sal;

long int phone;

struct node *prev;

struct node *next;

};

struct node *head=NULL,*tail=NULL;

int count=0;

void main()

int ch,n,i;

clrscr();

printf("1.Create DLL of Employees nodes using end insertion\n");

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)

printf("enter yourchoice for SLL operation \n");

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);

printf("\n Invalid choice");

break;

}
}

void insertend()

struct node *temp;

temp=(struct node*)malloc(sizeof(struct node));

if(temp==NULL)

printf("out of memory space\n");

exit(0);

printf("enter the ssn,Name,Department,Designation,salary,Phone NO. of the Employee:");

scanf("%s %s %s %s %ld %ld",temp->ssn,temp->name,temp->dept,temp->designation,&temp-


>sal,&temp->phone);

temp->next=NULL;

temp->prev=NULL;

count++;

if(head==NULL)

head=tail=temp;

else

tail->next=temp;

temp->prev=tail;

tail=temp;

}
}

void insertfront()

struct node *temp;

temp=(struct node*)malloc(sizeof(struct node));

if(temp==NULL)

printf("out of memory space\n");

exit(0);

printf("enter the ssn,Name,Department,Designation,salary,Phone NO. of the Employee:");

scanf("%s %s %s %s %ld %ld",temp->ssn,temp->name,temp->dept,temp->designation,&temp-


>sal,&temp->phone);

temp->prev=NULL;

count++;

if(tail==NULL)

temp->next=NULL;

head=tail=temp;

else

head->prev=temp;

temp->next=head;

head=temp;

}
void deletefront()

struct node *temp;

if(head==NULL)

printf("list is empty\n");

return;

else

temp=head;

head=head->next;

head->prev=NULL;

printf("\nThe Employee node with ssn %s is deleted\n",temp->ssn);

count--;

free(temp);

void deleteend()

struct node *temp;

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()

struct node *temp=head;

int num=1;

if(head==NULL)

printf("list is empty\n");

return;

else

printf("the elements in the list are\n");

while(temp!=NULL)

printf("\nNum:%d | SSN:%s | Name:%s | Department:%s |Designation:%s| salary:%ld |


ph:%ld|",num,temp->ssn,temp->name,temp->dept,temp->designation,temp->sal,temp->phone);

temp=temp->next;

num++;

printf("\n No of Employee nodes is %d\n",count);

void deqdemo()
{

int ch;

while(1)

printf("\n Dequeue demo using DLL\n");

printf("\n 1: Insertfront \n 2: Insertend \n 3:deleteend\n 4:deletefront\n 5: Display \n 6: Exit


\n");

printf("\n Enter your choice");

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;

You might also like