Program 8
Program 8
h>
#include<stdlib.h>
Struct node
Int sal;
};
Int count = 0;
NODE create()
NODE enode;
If (enode == NULL)
Exit(0);
}
Printf(“\n Enter 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);
Count++;
Return enode;
NODE insertfront()
NODE temp;
Temp = create();
If (first == NULL)
Return temp;
Return temp;
Void display()
NODE cur;
Int nodeno = 1;
Cur = first;
If (cur == NULL)
Nodeno++;
NODE deletefront()
NODE temp;
If (first == NULL)
Return NULL;
Printf(“\nThe employee node with the ssn:%s is deleted “, first -> ssn);
Free(first);
Count--;
Return NULL;
Temp = first;
Printf(“\nThe employee node with the ssn:%s is deleted “, temp -> ssn);
Free(temp);
Count--;
Return first;
NODE insertend()
Temp = create();
If (first == NULL)
Return temp;
Cur = first;
}
Cur -> rlink = temp;
Return first;
NODE deleteend()
If (first == NULL)
Return NULL;
Printf(“\nThe employee node with the ssn:%s is deleted “, first -> ssn);
Free(first);
Count--;
Return NULL;
Prev = NULL;
Cur = first;
{
Prev = cur;
Printf(“\nThe employee node with the ssn:%s is deleted “, cur -> ssn);
Free(cur);
Count--;
Return first;
Void deqdemo()
Int ch;
While (1)
Printf(“\n1:InsertQueueFront\n 2: DeleteQueueFront\n
3:InsertQueueRear\n 4:DeleteQueueRear\n 5:DisplayStatus\n 6: Exit \n”);
Switch (ch)
Case 1:
First = insertfront();
Break;
Case 2:
First = deletefront();
Break;
Case 3:
First = insertend();
Break;
Case 4:
First = deleteend();
Break;
Case 5:
Display();
Break;
Default:
Return;
Void main()
Int ch, I, n;
While (1)
Printf(“\n\n--------Menu--------“);
Printf(“\n2:DisplayStatus”);
Printf(“\n3:InsertAtEnd”);
Printf(“\n4:DeleteAtEnd”);
Printf(“\n5:InsertAtFront”);
Printf(“\n6:DeleteAtFront”);
Printf(“\n8:Exit \n”);
Switch (ch)
Case 1:
First = insertend();
Break;
Case 2:
Display();
Break;
Case 3:
First = insertend();
Break;
Case 4:
First = deleteend();
Break;
Case 5:
First = insertfront();
Break;
Case 6:
First = deletefront();
Break;
Case 7:
Deqdemo();
Break;
Case 8:
Exit(0);
Default: