Lab 5 - Array-Based Queues

The purpose of this lab is to implement the enqueue and dequeue operations for an array-based queue.

The file lab5.cpp contains most of the array-based queue code, including a menu function in main to manipulate the queue, except the enqueue and dequeue operations. As stated in lecture, the main issue with using a circular array for the array-based queue is efficiently incrementing and decrementing the index without using if statements to wrap the index back around. At the top of lab5.cpp are two preprocessor macros that provided a way to advance the index ahead by one (wrapping around to 0 when it exceeds the maximum allowed index) and decrement the index by one (wrapping around to MAX_SIZE-1 when the index falls below 0) using purely modulo arithmetic. Read the notations on how the decrement operation works, as that was not covered in lecture.

Your task for this assignment is to implement the enqueue and dequeue operations from the following pseudocode:

Enqueue:
  if queue is full
    print full queue error
    return false
  end-if
  add element to array index indicated by back index
  advance the back index
  return true

Dequeue:
  if queue is empty
    print empty queue error
    return false
  end-if
  set array index indicated by front index to "zero"
  advance the front index
  return true
Once you add the implementation for enqueue and dequeue, the menu will function as expected to add and remove items from the queue. You can use the debug report option to print out the "behind the scenes" state of the queue.

Email Terry your updated lab5.cpp file.