Question: COMPLETE THE CODE PLZ /* ************************************ */ /* Queues main Operations */ /* Inserting & Deleting Integer values into/from */ /* a Circular queue */

COMPLETE THE CODE PLZ

COMPLETE THE CODE PLZ /* ************************************ */ /* Queues main Operations *//* ************************************ */

/* Queues main Operations */

/* Inserting & Deleting Integer values into/from */

/* a Circular queue */

/* Insertion(I) and Deletion(D) Operationions */

/* End Of operation(E) */

/* ************************************* */

#include

#include

#include

#define MAXELEMENTS 5

#define TRUE 1

#define FALSE 0

// circular Queue insertion and deletion functions

//created for person

struct person

{

int empNo;

char name[12];

int age;

char gender[2];/* M=male, F=Female */

};

//the new queue, this queue takes "person"

struct queue

{

struct person allperson[15];

int front , rear;

};

//the prototypes will change, input to queue is struct person, output from queue is struct person

int main(void)

{

char operation;

int x;

struct queue q, male, female;

q.front = q.rear = MAXELEMENTS - 1;

struct 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};

do

{

//loop to insert persons into the queue

for(int i=0; i

cqinsert(&q , tenPerson[i]);

}

//delete from the queue

for(int i=0; i

struct person xx;

xx= cqdelete(&q);

//check if the gender in xx is male

if()

//insert in "male"

else

//insert in "female"

}

//delete for male

//delete for female

printf("%s ","Insert Operation type I D or E ");

scanf(" %c",&operation);

switch (operation)

{

case 'I':printf("%s ","Insert an element");

scanf(" %d",&x);

cqinsert(&q , x);

break;

case 'D':x=cqdelete(&q);

printf(" %d is deleted ",x);

break;

}

}

while (operation != 'E');

return 0;

}

int empty(struct queue *pq)

{

return((pq->front == pq->rear) ? TRUE : FALSE);

}

//output from queue is struct person

struct person cqdelete(struct queue *pq)

{

if (empty(pq)) {

printf("Queue underflow ");

exit(1);

}

if (pq->front == MAXELEMENTS - 1)

pq->front = 0;

else

(pq->front)++;

return(pq->items[pq->front]);

}

//input to queue is struct person

void cqinsert(struct queue *pq , int x)

{

/* make room for new element */

if (pq->rear == MAXELEMENTS - 1)

pq->rear = 0;

else

(pq->rear)++;

if (pq->rear == pq->front) {

printf("Queue overflow");

getchar(); getchar();

exit(1);

}

printf(" %d is inserted ",x);

pq->items[pq->rear] = x;

}

Experiment 1: Write recursive function for maximum, minimum et.c Experiment 4: Use the code provided to answer from sub-questions 1 to 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!