If you're selling your iPhone or iPad or passing it on to someone else, the first thing you'll want to do is make sure they won't have access to any of your personal data. Fortunately, iOS makes it very easy to wipe all your data off your old iPhone or iPad, no computer required.
Before doing this, you obviously want to make sure you either have an iCloud backup or an iTunes backup of your data. Otherwise, you won't be able to get your stuff back. Once you're sure you have a backup for your own use, proceed on.
Launch the Settings app from the Home screen of your iPhone or iPad.
Now tap on General.
Scroll all the way to the bottom and tap on Reset.
Tap on Erase All Content and Settings.
You will be prompted to confirm your selection, tap on Erase iPhone.
Once more you will be reminded that you can't undo this action, tap Erase iPhone one more time to confirm.
That's it. Your iPhone or iPad will reboot after a few minutes and all your personal data should be gone and again look like the day you pulled it out of the box.