If you are thinking to format your computer but are worried about the songs stored in the iTunes library, then do look at this post first.
The process below will guide you when you wish to format your computer but if you want to move your library to a new computer then read this post.
1. Since we are formatting only the root drive usually C: restoring the library is quite easy.
2. Assuming that your songs are stored in other drive than C: and are unmoved during the process, the library can be restored easily.
3. Open iTunes, click on Music tab on left and then go to File-> Library-> Export Playlist.
4. It will save all your songs and the details associated with them in a text file.
5. After formatting the computer, just click on Import Playlist to import this file back and this will restore all the songs back in your iTunes library.
NOTE: For restoration to be possible it is important that you do not move any song from its location else it will not be restored back. That means if your songs are saved in a folder then they should be present in the same folder after the format.