
You may also be asked to turn off Find My iPhone. To sign out of iCloud, go to Settings app, tap on your name shown with profile picture (this should be the first item just below the Search bar), scroll down and tap on Sign Out (last item shown in red). Once you have backuped up all the important user data, make sure you sign out of iCloud. The backup can be created either on iCloud or an Mac or a Windows computer using iTunes.

Also, make sure to create a backup of your iPhone if you wish to restore it to a new iPhone. The other crucial step to take before giving away your iPhone is to make sure you have synced all your important data (Contacts, Photos, Notes etc.) to iCloud. There's also an Apple support document titled Find the serial number or IMEI on your iPhone, iPad or iPod touch which is worth going through.

You can easily determine the IMEI and the serial number by going to Settings app → General → About and looking for fields named IMEI and Serial Number (along with host of other information).
