1. Originally Posted by DaveH
Thats what I thought, but wasn't sure. So i would be -1 and it would try to access the array. That would be attempting array access with an out of bounds index.
I wasn't aware that 0 - 1 + 1 equaled negative one. It's the new math!

2. Originally Posted by tabstop
I wasn't aware that 0 - 1 + 1 equaled negative one. It's the new math!
Okay, I see where I wasn't thinking correctly. i would be set to -1 inside the loop, but it would be incremented back to zero before the next loop iteration. But, this would become an infinite loop because : i=0, check arrary element at zero. That element is not valid. set i=-1. increment loop so i=0 again. repeat forever.

3. Originally Posted by DaveH
Okay, I see where I wasn't thinking correctly. i would be set to -1 inside the loop, but it would be incremented back to zero before the next loop iteration. But, this would become an infinite loop because : i=0, check arrary element at zero. That element is not valid. set i=-1. increment loop so i=0 again. repeat forever.
Except that the scanf was inside the loop, so we could get a new (hopefully valid) number.

4. Originally Posted by tabstop
Except that the scanf was inside the loop, so we could get a new (hopefully valid) number.
You are right. Ignore me.