I have code, in which I input each number on new line until I write 0. I am confused about size of array. In begining i declare that A is array with indices 1 to 5. But when I keep writing and put more than 5 numbers, it seems like it is still saved and then later used in second for cycle. How is that possible? I thought if i run out of indices I would get an error.
program testarray;
var hmez,
i:integer;
A:array [1..5] of integer;
begin
i:=0;
repeat
inc(i);
readln(A[i]);
if A[i]=0 then hmez:=i-1;
until A[i]=0;
for i:=1 to hmez do
writeln(A[i]);
end.