This is a really good question, but parts of Scott's answers need a bit of clarification.

Sorry bro.This is incorrect. Each ARTCC is allowed to assign a code from 0000 to 7777, with some of the exceptions being:
Code:
1200 - VFR
7500 - HiJack
7600 - Radio Failure
7700 - Emergency
7777 - Military Interception Procedures
That being said, there are tiny squawk code ranges that are assigned to each Class C TRACON and/or RAPCON's
within an ARTCC airspace boundary for the exclusive use of that facility. Two examples of this would be:
- A VFR aircraft transitions into Class C airspace. (It is plausible for an aircraft to stay @ 1200, but since an operation in Class C requires communications with ATC, often times ATC will assign a local code to squawk.) Once the aircraft has exited the Class C airspace, it is back to VFR 1200. "Radar service terminated, frequency change approved, squawk 1200, good day."
- A VFR aircraft transitions into Class C airspace, gets assigned a local code to squawk and then requests Flight Following. Upon exiting the Class C airspace the aircraft would be handed over to the Center just as if it were an IFR flight. The local code would be retained unless changed by ATC, the pilot discontinues Flight Following back to VFR, or the flight ends due to it's arrival at the destination.
The exception to this is VFR entry into Class B airspace since it requires a CLEARANCE, (you will get a code ... no and's, if's, or but's here.) and all flights in the DC ADIZ. All other squawk codes issued will be from an ARTCC's pool. The main thing to remember here is that all codes active within an ARTCC's airspace will not be duplicated
within that ARTCC's airspace.
With THAT being said, if an aircraft with a code of 1234 crosses a Center boundary where a code of 1234 is already active, a new code will be automatically be generated from the pool and presented to the controller for reassignment.Correction, nearly all aircraft checklist's have the transponder to be set to
Standby and squawk code set somewhere after engine start. Then somewhere after taking the active, the transponder is set to
On or
Alt (depending on equipment type), lights on, DG aligned with compass and runway, go with throttle up!