You haven't provided the input file so we can't run it, and while you've given a description of what goes wrong, you haven't explained what the program is SUPPOSED to do. InputMatrix is commented out, so I'm guessing that's where your problem is. I imagine it gave you compile errors since your function declaration is this:
void InputMatrix(int matrix[][J], int matrix2[][J]); and your function call is this:
InputMatrix(matrix, matrix2); where matrix1 and matrix2 are declared as integers. You can't pass integers to a function that is expecting arrays. It looks to me like nothing else can be done in your program until that problem is solved. I don't see how you even got the output that you did get. You never read in the array so how can you display it? Thus if it prints gibberish, that makes sense since you've never put anything into the array. You are printing whatever was already in those memory locations, which could be anything.