I have a home PC that I don't use anymore, mainly because my wife and I each have laptops and the PC developed a sick hard drive. It chatters and clicks out what appears to be morse code

. The computer is aprox. 7-8 years old and other than that it works/worked fine. I have removed the hard drive and may sell the PC at a garage sale as is. But I was wondering if I could install a cheap hard drive maybe I can donate it to a local school and get better use out of it. So the question is how do you install a new hard drive? I know how to mechanically install it and how to wire it but how do you install the operating system? Is there already a bare minimum of software loaded into the hard drive and it will prompt the user to do the correct stuff to install the O.S.? You can tell by my questions I'm not too computer savvy

Any help out there guys?