You have arrays with sizes of 20. But in all your loops you are iterating over 21 items:
for(i=0;i<=20;i++)
With the last iteration you are accessing the item
array[20]
but allowed indexes are from 0 to 19. This is called out of bound access. What happens can't be predicted. While reading just returns wrong values, writing will overwrite other data and may result in an access violation.