This program described below is a part of a simple queue program. Write your own
ID: 3740912 • Letter: T
Question
This program described below is a part of a simple queue program. Write your own custom_clearQueue', 'custom_enqueue', and 'custom_dequeue' to make the program work. (You can add any sub-routines or variables, if you'd like). And, you need to report specifically two numbers that are displayed on your screen (console) in sequence. void custom_clearQueue (void); void custom_enqueue(unsigned char) unsigned char custom_dequeue(void); static unsigned char queue_data[255]; static unsigned char queue tail; static unsigned char queue_head; int main() unsigned char tx_data]-{ 5', '4, '3', '2', '1' , rx data; int kp; custom clearOueue for (kp-0; kpExplanation / Answer
FORM THE GIVEN DATA WROTE A PROGRAM AS SHOWN BELOW
(SEQUENCE NUMBERS 5 AND 4)
int rear = -1;
int front = -1;
void custom_enqueue(unsigned char value){
if(rear == 254)
printf(" Queue is Full!!! Insertion is not possible!!!");
else{
if(front == -1)
front = 0;
rear++;
queue_data[rear] = value;
queue_tail = queue_data[rear];
queue_head = queue_data[front];
}
}
unsigned char custom_dequeue(){
if(front == rear)
printf(" Queue is Empty!!! Deletion is not possible!!!");
else{
unsigned char deleted = queue_data[front];
front++;
queue_head = queue_data[front];
if(front == rear)
front = rear = -1;
}
return deleted;
}
void custom_clearQueue(){
front = -1;
rear = -1;
queue_head = '';
queue_tail = '';
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.