Because of earlier logic not going to deque the last element of the queue because at the last front == rear as per your logic which directly results in "Underflow".