Directly implement the simple Dequeue structure learned in class. The Enqueue function puts an element in the queue and the PrintAll function displays all the elements in the queue. The same functions implemented in the last open lab are used. The program should continue to receive input until the user chooses to end it. The user can select different options: entering 1 and an element will enqueue the element, entering 2 will dequeue an element, entering 3 will execute the PrintAll function, and entering 0 will end the program.
Restrictions:
- Global variables cannot be used.
- Dynamically allocated variables/structures must be freed when the program ends.
The prototypes of structures and functions are as follows:
typedef struct node{
int data;
struct node* next;
} QUEUE_NODE;
typedef struct {
QUEUE_NODE* front;
QUEUE_NODE* rear;
int count;
} QUEUE;
void Exit(QUEUE*);
void Enqueue(QUEUE*);
void Dequeue(QUEUE*);
void PrintAll(QUEUE);
Result:
----- Menu -----
- 0 : Exit
- 1 : Enqueue
- 2 : Dequeue
- 3 : Print All
Select > 1
Input Data > 10
Select > 1
Input Data > 20
Select > 2
Select > 3
20
Select > 1
Input Data > 30
Select > 3
20 -> 30
Select > 0
Please help me write the code in C programming language. Pay attention to the conditions.