The same way you're writing into the integer array at each step of your loop, at this line: cin>>array[i];
array[index] can be used for getting a value stored at a certain index just as it can be for writing to a certain element of an array. Use it like you might a normal variable.