Final answer:
To diagnose a computer that randomly turns off with a functional HDD and RAM, test the power supply first, as it is likely to cause such issues. Other components to check include the cooling system, motherboard, and graphics card.
Step-by-step explanation:
If a computer is randomly turning off and you're sure the HDD (hard drive) and RAM (memory) are both functional, the next component you may want to test is the power supply. This is because an inconsistent or failing power supply can cause the computer to shut off unexpectedly. However, it's also important to consider other factors that might cause the computer to turn off. For example, overheating could lead to a shutdown to prevent damage to components, so checking the cooling system is also a good step. The motherboard could be another culprit if it has developed a fault. Lastly, while less likely to cause shutdowns, a faulty graphics card could be the issue if it's causing overheating or drawing too much power.