Reverse An Array whats wrong with this type of code?
Notice that you increment $p$, whilst also decrementing $n$. Since your condition in the while loop is that p &lt; n, then the while loop will only work for half the elements.
Also, note that you delete the last $n/2$ values, since you modify them without first reading them.