Question: look at the photo, there is already code you will just need to add some points, answer should be correct and similar code Experiment 4
look at the photo, there is already code you will just need to add some points, answer should be correct and similar code



Experiment 4 (PreLab task-to be prepared in advance by the student) (to write a COMPLETE C program) Prepare a menu driven C program for Inserting and deletion operation for a queue structure of employee information which has the following structure declaration. Structure of a queue will be defined as follows. struct person { int empNo; char name[12]; int age; char gender[2];/* M=male, F=Female */ }; struct queue { struct person allperson[15]; int front, rear; Define the following Initialized array of structure in your program. sruct person tenPerson[10]={123,"Ahmet", 21, "M", 234, "Sevgi", 26, "F", 128,"Osman", 18,"M", 432,"Mert", 27,"M", 287,"Ayse",34,"F" , 423,"Kemal", 21, "M",634,"Lale", 16, "F", 828,"Sefer", 15,"M", 252,"Meral", 27,"F", 887,"Demet",34,"F"}; Following steps of operations will take place in your menu driven program. 1. Create a Circular queue using tenPerson array structure(copy from array into queue will be done). 2. Delete all the elements of queue and list all the deleted from the monitor. 3. Using circular queue which is populated at step 1, Create two new circular queues, one for Male and one for Female employees. These new queues will be created during the deletion of circular queue and use gender fields for determining Male(M) and Female(F) queues. 4. List the content of Male queue and Female queue during delete operation of each queue. 5. End of operation 44 do { 45 46 47 48 49 50 51 //loop to insert persons into the queue for(int i=0; i 52 53 54 55 56 57 58 59 //delete from the queue for(int i=0; ifront == pq->rear) ? TRUE : FALSE); } 96 97 98 99 100 101 102 103 104 105 106 107 108 109 //output from queue is struct person struct person cadelete(struct queue *pg) { if (empty(p)) { printf("Queue underflow "); exit(1); } if (pq->front == MAXELEMENTS - 1) pq->front = 0; else (pq->front)++; return(pq->items[pq->front]); } 110 111 112 113 //input to queue is struct person void coinsert(struct queue *pq, int x) { /* make room for new element */ if (pq->rear == MAXELEMENTS - 1) pq->rear = 0; else 114 115 115 else 116 (pq->rear) ++; 117 if (pq->rear == pq->front) 118 printf("Queue overflow"); 119 getchar(); getchar(); 120 exit(1); 121 122 printf(" %d is inserted ",x); 123 pq->items[pq->rear] = x 124 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
