I am just learning Pascal at school and have run into a weird problem in my assignment.
What I need to do is create two arrays and then read in integers for the first array until 10 numbers are read or a negative number is read, then move on to the second array with the same rules.
I have that all working fine except for the first number in the second array is always messed up. -1 seems to always be copied to array 2 index 1.
I can't give away to much code because this is an assignment but it is something like this:
while input >= 0 and index < 10 do
begin
read(input);
array1[index] := input;
index++
end;
input:= 0; //to reset it
another while loop but for list2...
If I input for array1 1, 2, 3, -1 and array2 1, 2, 3, 4, -1 my output would be something like:
list 1: 1 list 2: -1
list 1: 2 list 2: 2
list 1: 3 list 2: 3
list 1: -1 list 2: 4
Does this make sense? I just need a little help understand why this is happening, I'm stuck here.