Program quits after data input?

Dear all,
PLEASE READ THE QUESTION AND SEE IF YOU CAN FIGURE OUT WHY MY PROGRAM QUITS!

Suppose you got yourself drunk after a night out and you are about to go home. You
are so intoxicated that for every step you take there is an equal probability that you
either move forward by one step, or move backward by one step. Assuming that you
are at the starting position 0. If you are allowed to take exactly one step, then you
either end at at positions +1 or −1. If you are allowed exactly two steps starting at
position 0, then you either  end up at positions −2: Take two steps back.  0: One step forward, followed by one step back; or one step backward, followed
by one step forward.  +2. Take two steps forward.
If you are allowed exactly three steps, then you end up at positions −3, −1, 1 or 3.
In general, if you are allowed to take n steps, you would end up at n + 1 different
positions. Moreover, you will always end up in odd positions if n is odd, and even
positions if n is even.
: The getDrunk function simply performs the walk and moves forwards or backwards
without regards to whether it is out of the bounds of the array. At the end of
every trial, increment the final position by one. Every trial should begin at the
same starting location. In the main function, you have to ensure that getDrunk
receives the correct starting position in the array, such that the walk will always
be within the array.