The problem is the two print functions. One of them is printing the global (and unused) array.

You seem to have some sort of deeper misunderstanding. Firstly, you are passing arrays and variables to each function (as you should). Therefore you don't need the globals at all. In this case, if the needless globals weren't there you would have got a compiler error pointing you to the problem line.

Secondly, I don't see how printTable and printTable2 differ. You can pass different arrays to a single function (and the names inside the function and in the calling function don't have to be the same). So, you now probably see how copy'n'paste programming backfires.