Answer:
rear = rear+1%n;
Step-by-step explanation:
rear = rear+1%n;
Where n is the size of the queue.
Modulus returns the remainder of the two operands. For example, 4%2=0 since 4/2=2 with no remainder, while 4%3=1 since 4/3=1 with remainder 1. Since you can never have a remainder higher than the right operand, you have an effective "range" of answers for any modulus of 0 to (n-1).
With that in mind, just plug in the numbers for the variables ((4+1)%5=? and (1+1)%4=?). Usually to find the remainder you would use long division, but one useful thing to remember is that any number divided by itself has a remainder of 0, and any number divided by a larger number will have a remainder equal to itself.
Hence the boundary condition achieved is when at given position there is already an element which is present hence it will break the loop and element would not be ensued until position is free.