In this problem, you need to implement a First In First Out (FIFO) queue in C using a circular array. You only need to write body of the functions given in the code editor. We have an array named
queue to store our queue. The maximum size of the queue, called the capacity of the queue is 5 for this problem. You are given the front and rear locations of the queue in the array. Initially both are set to -1.
front variable stores the head or the starting location in the queue, while
rear variable stores the last filled location of the queue. You need to implement the following functions in C:
- int isEmpty() - Should return 1 if the queue is currently empty otherwise 0.
- int isFull() - Should return 1 if the queue is currently full otherwise 0.
- int queueSize() - Should return an integer from [0-5] which is the number of elements currently in the queue.
- void enQueue(int) - It takes an integer as parameter, and stores this at the rear end of the queue. If the queue was full, then it simply ignores this value. Overall this function is of void type and returns nothing.
- int deQueue() - If the queue is empty it returns -1, otherwise it pops an element from the front of the queue and returns it.