Remove all furniture from the room. The carpet needs to be pulled up, so everything must be out of the way.
Pull up the carpet and the subfloor to expose the area where the squeak is located (Image 1).
Note: A squeaking noise is often the result of friction between two boards. This can be easily fixed by creating a kerf -- or gap (Image 2). To create this gap between the sheets of plywood, use a circular saw. Cut only to the depth of the plywood.
Once you've created the gap, that will allow the boards to move independently from each other; properly secure them in place. You should be right over the floor joist and the nail should go in at an angle. This is called toenailing. If you go in straight, the plywood can ride up and down the nail.
If there's an improperly nailed down nail, first remove the existing nails. Use the same toenailing technique to re-nail the boards down.
Once all the boards have been properly secured, the subfloor can be replaced. Use glue to seal between the subfloor and the joists. Apply wood glue to the top of the joists in a serpentine motion and replace the plywood.
Once all squeaks and creaks have been silenced, replace the carpet.