This is a good question. It is being caused by the input of 'q' into an int (the array), but I can't explain why it is behaving as it is.
I tried running it, adding a printf to trace it and found that after entering 'q', it stopped asking for data, but continued to print and increment size within the loop for the full 20 passes.
I changed the code to detect when a 0 is entered and it worked as expected, so it's clearly the entry of 'q' that is triggering the behavior. But, why are some lines of code within the loop being executed and others are not?
That's WHAT is causing the problem. What I don't understand is why the program continues to cycle through the for loop, and why it is incrementing size++, but not executing the scanf command? Perhaps @kareem or someone far more versed in c can explain this.