Question: USING C language Pleaes ( Code provide below ) #define _CRT_SECURE_NO_WARNINGS #include #include typedef struct list_tag { int data; struct list_tag * next; } ListNode;

USING C language Pleaes ( Code provide below )

USING C language Pleaes ( Code provide below ) #define _CRT_SECURE_NO_WARNINGS #include

#define _CRT_SECURE_NO_WARNINGS #include #include

typedef struct list_tag { int data; struct list_tag * next; } ListNode;

typedef struct { ListNode * first; ListNode * last; } queue;

void queueInsert (queue * qp, int t); void queuePrint (queue q); void queueInit(queue * qp);

void main(){

queue my_queue; int data;

queueInit(&my_queue); //Initialize the queue as empty printf("Give me numbers. 0 = exit "); scanf("%d",&data);

while (data != 0){ queueInsert(&my_queue, data); scanf("%d",&data); } queuePrint(my_queue); printf("Bye "); // system("pause"); Uncomment this to see the output in window }

void queueInit(queue * qp){ qp->first = NULL; qp->last = NULL; }

void queueInsert (queue * qp, int t){

ListNode * n = (ListNode *) malloc(sizeof(ListNode)); if (n == NULL) { printf("Out of memory "); exit(1); } n->data = t; n->next = NULL; if (qp->last == NULL) qp->first = qp->last = n; else { qp->last->next = n; qp->last = n; } }

void queuePrint (queue q){

printf("Now I will print the queue "); ListNode * n; for (n = q.first; n != NULL; n = n->next) { printf("%d ", n->data); } }

Section 1 Compile and run the code that it is provided to you (queue.c). What does it do Make all the necessary changes so that the program creates two queues. One queue for odd numbers and another for even numbers. Each queue stores the number that the user enters (e.g. if the user enters 2 it stores this data to the odd queue, if the user types 3 it stores this number to the even queue etc. Print the two queues separately by using the queuePrint function Section 2 (a Modify the provided code (queue.c in order to print the queue in the reverse order. (b) Modify the provided code (queue.c so as to use a cyclist list instead of a single linked list

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!