What Gary said....
In my experience, the most common problem with a symptom of unscheduled rebooting in a DESKTOP is associated with the main power supply becoming overheated. The power supply has an internal fan and it can become clogged with dust or just fail. Inspect the power supply fan. Where is it? Just follow the power cord connection to the desktop. The power cord is usually detachable and it plugs into the power supply.
Other components within the computer that require adequate cooling can also contribute, so yank a panel off and inspect.
I blow mine out twice a year using compressed air ( I have 4 desktop servers). I disconnect them, take them to the garage and using my garage air supply, just get all of the dust out of everything, paying special attention to the power supplies, cpu cooler fans and graphic cards.
Good Luck,
Reggie