Whether you're handing over your old iPhone or iPad to a family member, or selling it on in order to upgrade (maybe you just bought an iPad Air or iPhone 5S) you should reset it to delete your accounts - including your Apple ID, Facebook, ebay, email and other accounts - and remove all your content including apps, photos and music.
The same goes for when you need to take it in for repair or replacement with Apple. Of course, before you reset your device, you should make a full backup as you might otherwise lose data.
Even if you use iCloud, it's sensible to make a full backup by connecting your iPad or iPhone to your computer, waiting for it to show up in iTunes (the current version is 11.1), and then clicking on it. It should open the Summary screen, where you'll see a Backups section. Simply click the Back Up Now button.
Once that's done, you can begin the wipe proces. It's also worth remembering to remove your SIM card before you pass on the iPhone or iPad on, as this may have information stored on it, and you might want to continue using it in a new handset or tablet.
We've used and iPad running iOS 7, reviewed, but it's exactly the same on an iPhone and there's no difference in the steps if your deivce is still running iOS 6.
Tap Settings, then General. Scroll down until you see Reset.
Tap Erase All Content and Settings. Depending on whether you've set a Passcode and / or a Restrictions Passcode (they are different) you might have to enter that code or password in order to erase and reset it.
Just in case you tapped the button by accident, your iPhone or iPad will ask you to confirm the reset, and when you tap OK it will start the process. This can take a minute or two, after which you'll see the welcome screen that you see on any new iDevice running iOS 5, 6 or 7. It's then ready to be sold on or taken to an Apple Store for repair.
Note that, if you're merely having a problem where your iPad or iPhone has frozen for some reason, you can hold down the power and home buttons to do a soft reset (a reboot). This type of reset doesn't delete and apps or data.