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

REDUCED 8TH PROGRAM OF DLL

The document contains a C program that implements a doubly linked list (DLL) for managing employee records. It allows users to create employee nodes, display the list of employees, and insert new employees at the front of the list. The program includes functions for creating nodes, displaying their details, and a menu-driven interface for user interaction.

Uploaded by

0shivathefighter
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

REDUCED 8TH PROGRAM OF DLL

The document contains a C program that implements a doubly linked list (DLL) for managing employee records. It allows users to create employee nodes, display the list of employees, and insert new employees at the front of the list. The program includes functions for creating nodes, displaying their details, and a menu-driven interface for user interaction.

Uploaded by

0shivathefighter
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

REDUCED 8TH PROGRAM OF DLL

#include<stdio.h>

#include<stdlib.h>

struct node

char ssn[50],name[50],dept[50],designation[50];

int sal;

long int phone;

struct node *llink;

struct node *rlink;

};

typedef struct node* NODE;

NODE first = NULL;

int count=0;

NODE create()

NODE enode;

enode = (NODE)malloc(sizeof(struct node));

if( enode== NULL)

printf("\nRunning out of memory");

exit(0);

printf("\nEnter the ssn,Name,Department,Designation,Salary,PhoneNo of the


employee:\n");
scanf("%s %s %s %s %d %ld", enode->ssn, enode->name, enode->dept, enode-
>designation, &enode->sal, &enode->phone);

enode->llink=NULL;

enode->rlink=NULL;

count++;

return enode;

NODE insertfront()

NODE temp;

temp = create();

if(first == NULL)

return temp;

temp->rlink = first;

first->llink = temp;

return temp;

void display()

NODE cur;

int nodeno=1;

cur = first;

if(cur == NULL)

printf("\nNo Contents to display in DLL");

while(cur!=NULL)

{
printf("\nENode:%d||SSN:%s|Name:%s|Department:%s|Designation:%s|
Salary:%d|Phone no:%ld", nodeno, cur->ssn, cur->name,cur->dept, cur->designation, cur->sal,
cur->phone);

cur = cur->rlink;

nodeno++;

printf("\nNo of employee nodes is %d",count);

void main()

int ch,i,n; while(1)

printf("\n\n~~~Menu~~~");

printf("\n1:Create DLL of Employee Nodes");

printf("\n2:DisplayStatus");

printf("\n3:InsertAtfront");

printf("\n4:Exit \n");

printf("\nPlease enter your choice: ");

scanf("%d",&ch);

switch(ch)

case 1 : printf("\nEnter the no of Employees: ");

scanf("%d",&n);

for(i=1;i<=n;i++)

first = insertfront();
break;

case 2: display(); break;

case 3: first = insertfront(); break;

case 4: exit(0);

default: printf("\nPlease Enter the valid choice");

You might also like