my compiler runtime checker - informs me that Line 47:elseif(r == py && c == px)
is a problem because variablepy and px are still uninitialised (when the program reaches that point).
So we can start by curing that problem.

That for loop starting on Line 28 - sure looks weird - but i suppose the consecutive if/else clauses make it a single statement loop.

Here is a Work In Progress, with color added (and some minor mods) with comments.
TODO:
1. Stop characters being able to move outside game grid
2. Possible timer - To allow automatic movement of the missile (is that what it is?) and the goblin.

Well you will need either a default case that takes you back to the beginning, or a condition on the while loop, since if the user doesn't input anything, the case is basically skipped. Also...why do you have x += 0, y += 0, etc...those do nothing...

Now I did see something strange: The first hit, with the arrow (yep, is a arrow, not a missile), the goblin dosen't suffer nothing, and the secondtie he does gain 40 health... Then the third shot he dies... Why that happens??