My compaq pc keep restarting

Welcome to Tom's Hardware Forums
A couple of questions for clarification,
What model Compaq?
How old?
Have you upgraded any hardware recently?
Have you updated any software recently?

Offhand I would venture the power supply is failing but unless you have a spare power supply to test that theory with, we would be better served to go through some troubleshooting rather than pay out only to find that isn't the problem.