Your expe keeps building because you keep adding itself with the new random exp to itself. If you want to just add the amount of exp for killing that goblin then you need to just assign the random exp gained to expe (like you did for loot). In other words change expe = expe + rand() % 10 + 1; to expe = rand() % 10 + 1;
As for the show exp until next level part it looks like you would need to take the next level exp required and subtract the texp you have from it. Or you can restructure the exp system and have variables called currentExp, expToLevel and currentLevel.
So random some exp after you kill the NPC and add that to currentExp and check if it becomes greater than ExpToLevel. If it is then go currentExp = currentExp % expToLevel (this will carry the extra exp from "over leveling" to the next level) and add 1 to level. Then just make expToLevel = currentLevel * 50 meaning that if you are level 1 then you need 50 exp, level 2 100 exp and so on.