Let's calculate the total number of marbles gained and lost by Ranjan.
In 8 games, he lost 5 marbles each, so the total loss is 8 * (-5) = -40 marbles.
In 4 games, he gained 4 marbles each, so the total gain is 4 * 4 = 16 marbles.
To find the total number of marbles Ranjan had at the end, we need to add the gains and losses to the initial number of marbles.
Total marbles = Initial marbles + Gains - Losses
Total marbles = 60 + 16 - 40
Total marbles = 76 - 40
Total marbles = 36
Therefore, Ranjan had 36 marbles at the end.