Computer shuts down often and over heats up

Hi,
I am facing a weird issue with my computer. When it turns on, I am able to work for some time and then it shuts off automatically for no reason. For many days I was facing this problem and I have tried booting into safe mode. I Even performed a repair install of OS, hoping it would help solve the problem. But the problem remained the same.
One day, I also noticed that my computer was getting overheated. So is this problem because of overheating? If yes, what would I be able to do about this problem?
