You just bought an iPhone or iPad (new or used) and you want or need to change your iCloud account, nothing more than normal. The procedure for changing accounts varies depending on the device you have.
Steps
Method 1 of 3: Switch iCloud account on iPhone or iPad

Step 1. Open Settings
This application is on the home page of your iPhone, it is represented by a gray icon containing a cogwheel (⚙️).
If you would like to change your iCloud account on a second-hand iPhone or iPad, click here ↓

Step 2. Touch your Apple ID
It's in the section at the top of the menu, where there's your name and possibly an image.
If your device is running an older version of iOS, just tap iCloud

Step 3. Scroll down and touch Sign Out
This button is at the very bottom of the menu.

Step 4. Enter your password
In the dialog box, type the password associated with your Apple ID.

Step 5. Touch Disable
The button is at the bottom right of the dialog box. In doing so, you deactivate the function Find my iPhone currently in use on your device.

Step 6. Select the data to keep
To do this, drag all the buttons of the iCloud data that you want to keep on your iPhone, like your contacts or your apps, to the green position.
If you want to delete all iCloud data from your device, make sure all the buttons are white

Step 7. Touch Sign Out
You will find this mention in the upper right corner of the screen.

Step 8. Touch Sign Out
By pressing this button, you confirm that you want to sign out of the iCloud account currently associated with your device.

Step 9. Open Settings
This application is on the home page of your iPhone, it is represented by a gray icon containing a cogwheel (⚙️).

Step 10. Touch Connect to your (iPhone / iPad)
This button is at the top of the menu.
-
To create a new Apple ID, under the password field, touch Forgot Apple ID or Password?
Then follow the onscreen instructions to get an Apple ID and iCloud account.
- If your device is running an older version of iOS, just tap iCloud.
Step 11. Enter your Apple ID and password

Step 12. Touch Connect
You will find it in the upper right corner of the screen.
- Repeatedly, as the connection is in progress, your screen will display Sign in to iCloud.

Step 13. Enter the passcode for your device
You must enter your device lock code, the one you set during initialization.

Step 14. Merge your data
If you want your contacts, notes, photos, calendars, reminders, or any other data stored in your device to be merged into your iCloud account, tap Merge, otherwise touch Do not merge.

Step 15. Touch iCloud
You will find this mention in the second section of the menu.

Step 16. Choose the type of data to store in iCloud
In the Apps using iCloud section, drag all the buttons that interest you to the green position.
- Everything you have selected will then be available on your iCloud account and on all devices connected to that account.
- Scroll down to see the full list of apps that have access to iCloud.
Method 2 of 3: Switch iCloud account on Mac computer

Step 1. Click on the Apple menu
You will find the famous black apple-shaped icon at the top left of the screen.

Step 2. Click System Preferences
You will find this mention at the top of the second section of the drop-down menu.

Step 3. Click iCloud
The icon is on the left side of the window.

Step 4. Click Sign Out
You will find this mention in the lower left corner of the window.
- All of your iCloud data, like your calendar or photos, will be deleted from your computer.
- If an error message appears while disconnecting, it's probably because there is a conflict with your iPhone or another iOS device. Open your device settings, tap your Apple ID, then tap iCloud, touch again Clothing and slide the button ICloud Keychain on the green position.

Step 5. Click on the Apple menu
You will find the famous black apple-shaped icon at the top left of the screen.

Step 6. Click System Preferences
You will find this mention at the top of the second section of the drop-down menu.

Step 7. Click iCloud
The icon is on the left side of the window.

Step 8. Click Connect
This mention at the top of the dialog box.
- To create a new Apple ID, under the Apple ID field, click Create an Apple ID …, then follow the onscreen instructions to have a new Apple ID and create an iCloud account.

Step 9. Enter your Apple ID and password
In the right frame of the dialog box, type your email address and the password associated with your Apple ID.

Step 10. Click Connect
You will find this mention in the lower left corner of the dialog box.

Step 11. Change the configuration settings for the iCloud service
As this is a sensitive feature, you need to enter your administrator name and the associated password.
If you are asked to enter the lock code of another (mobile) device, then you have enabled two-step verification in the past

Step 12. Choose your synchronization preferences
In the dialog box, check the box at the top if you want your calendars, bookmarks, contacts, and other notes to be stored in your iCloud account. Check the bottom box if you want to activate the function Find my Mac.

Step 13. Click Next
You will find this mention in the lower left corner of the dialog box.
- Click on To allow to activate Apple's location service on your Mac computer.

Step 14. Check the box next to iCloud Drive
This will allow you to store your files and documents in your iCloud account.
- Choose which apps will have access to iCloud. To do this, in the dialog box, click on the button Options which is near iCloud Drive.

Step 15. Select the data you want to sync with iCloud
This is done by checking the appropriate boxes under the mention iCloud Drive. So if you check Pictures, you will save them to iCloud and you can find them whenever you want. All the data you select will be in iCloud and you can access it from any device (mobile or not) connected to this iCloud account.
Scroll down if you have a lot of different data
Method 3 of 3: Switch iCloud account on a used iOS device

Step 1. Contact the previous owner of your device
If you bought a used iPhone and find that the previous owner forgot to delete their iCloud account, ask them to delete it. There is no other solution than this so that you can create your own account, even if you have done a restore to factory settings.

Step 2. Have it go to the iCloud website
There, he can connect to his account and he can disconnect it from his old device. Normally, your salesperson will have done this already, but if they haven't, ask them to do it by possibly directing them to icloud.com. Explain the process if necessary.

Step 3. Tell him to click on the settings button
Once on the iCloud site, your seller should open the settings page by clicking this button.

Step 4. Tell it to click on your device
Indeed, if the account has not been desynchronized, his device is still in the list of his devices. Clicking on your device icon will open a window with lots of iPhone details.

Step 5. Tell it to click on the X button next to the iPhone name
In doing so, the device is disconnected from the iCloud account of the previous owner. When it is done, it will notify you and you can then sign in with your own iCloud account.