You'll want to connect it to a computer and restore the software using iTunes.
For your second question; yes! You can do the backup through iTunes as well.
http://support.apple.com/kb/HT1414?viewlocale=en_US - How to Restore
http://support.apple.com/kb/HT1766 - How to Backup (both iTunes and iCloud)
Make sure you do the backup before you do the restore.
Before you wipe, make a backup on iTunes as well as iCloud.
Wipe iPhone/iPad/iPod touch clean
Switch off iMessage in Settings > Messages
Switch off FaceTime in Settings > FaceTime (iPod touch 4th Generation or later, iPhone 4 or later and iPad 2 or later)
Delete iCloud in Settings > iCloud > Delete Account
Finally Settings > General > Reset > Erase All Content and Settings.
Un-register your device: https://supportprofile.apple.com
Now you can sell/give.