When you come to sell your iPhone or iPad - or even give it to a family member - you should erase all the data and restore it to factory settings to avoid handing anyone your personal details, logins, photos and more. The same goes for when you need to take it in for repair or replacement with Apple. Before you reset your device, you should make a full backup as you might otherwise lose data.
Delete your data, apps, music, photos and more from your iPhone or iPad
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), 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 reset process on your iDevice. It's also worth remembering to remove your SIM card before you pass the the iPhone or 3G/4G iPad on, as this may have information stored on it, and you might want to continue using it in a new handset or tablet.
(Note that we've used iPad screenshots here, but it's exactly the same on an iPhone.)
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 or 6. 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.