The iMac you have came w/system DVDs. See KB Article: http://support.apple.com/kb/HT1159
You will need to get them from the person that gave you the iMac. If that is not possible you can get replacement System Install & Restore CD/DVDs from Apple's Customer Support - in the US, (800) 767-2775 - for a nominal S&H fee. You'll need to have the model and/or serial number of your Mac available.
If you're not in the US, you may need to go through the regional Apple Store that serves your location to find the contact number. Here's a list of links to all of those - http://store.apple.com/Catalog/US/Images/intlstoreroutingpage.html Another resource: International Support Phone #s.
================
After you receive the system DVDs read the info in the links listed below as they also apply to you.
What to do before selling or giving away your Mac
Preparing an old Mac for sale
How to prepare your Mac for sale
Clicky click--—> Erasing disks securely
================
Start up from your install disc, go to Disk Utility and select the disk and click erase - to securely erase data click Security Options and Erase Free Space which will entirely wipe your disk, overwriting it with zeros so that no data is recoverable.
See KB Articles: http://support.apple.com/kb/PH10727 OS X Mountain Lion: Restore your computer’s software
http://support.apple.com/kb/ph11273 OS X Mountain Lion: Erase and reinstall OS X
http://support.apple.com/kb/PH6817 Mac OS X 10.6: Restoring your computer’s software
http://support.apple.com/kb/PH3840 OS X Lion: Restore your computer’s software
Good luck!
