When your PC goes wrong and you have lost all hope the normal final stage is to reformat your computer and start afresh. This will most likely resolve any software issues, remove viruses or any other nasties and give you a clean start. But what happens if you have already reformatted and the problem still exists?
This means, most likely, you have a hardware fault. This is where problems can start.
Diagnosing a computer hardware fault can be a right pain as any of the computer components could the cause. Unless you are intending to replace the entire machine you need to carefully diagnose with what components the fault lies with.
I would advise you look at the computer into these main areas to analyse.
Memory / RAM
Power Supply
Hard Disk
Motherboard
This isn't a complete definitive list, obviously depending on your issue ie if your issue is that you don't get sound then it could be a sound card issue, similarly if you don't get a display then graphics could be the culprit. If it is a random fault then either of the above could be the cause.
Memory - this is fortunately quite easy to diagnose. Search the Internet for a memory tester. Generally these can be put onto a CD (or Floppy if you are stuck in the past!!), boot up from the CD which then enters the memory test. This will constantly cycle through, testing the memory for errors. It is wise to leave this on for several hours or even better over night. It will advise you if the memory fails.
Power Supply - this can be a strange one. People generally assume that if the power supply does fail then you would get no life from you computer at all. This sometimes is not true. I have had computers that turn off at random times, computers that have the power light on, but do not start up etc and it has turned out to be the supply - I would advise this should be one of the first things to test as can be a problematic area. Testing it can be difficult without the right equipment. Really the only way is to get a volt tester and check the voltage and current coming out.
Hard Disk - this can be one of the worst problems to have as if your hard disk does fail, unless you have been sensible and done regular backups of your most valuable data, you stand to lose it all. Hard disks can go at any time and usually you will hear a harsh sounding clicking noise that is coming from your computer. If this is the case you need to probably replace the hard disk. Get someone who then knows what they are doing here to try and recover your old data for you.
If none of the above solves your problem then you could possibly be looking at the fault being with the motherboard or any other plug in cards or devices you have. Remove everything to leave only the very basics. Take out all sound cards etc and any other PCI devices that are not essential. If you have more than one stick of ram then leave in only one and see if the problem resolves.
Really, solving hardware issues comes down to a case of trial and error here so take the time to test everything out. Bear in mind that even if your keyboard or mouse is faulty, very strange things can happen to a computer, so if you can, try to remove and test every single item.