In the US, all IFR aircraft need a clearance to be in class A, B, C, D, and E airspace. Does this mean that all aircraft with clearances need to be assigned squawk codes by ATC when they enter?
/X (VOR only), /D (VOR/DME only), /Y (LORAN only), and /M (TACAN only) aircraft do not have transponders. Primary-only aircraft can be assigned flight plans, and fly IFR. It's not common, though, because aircraft that will fly within 30 miles of class B airspace, or aircraft that will operate above 10,000 feet MSL are required to be equipped with transponders and Mode C altitude reporting, similar to the ADS-B requirements. (14 CFR § 91.215)
Yes. Every aircraft needs to be assigne a discrete code to allow radar systems to correlate flight plan data with the radar target and to enable identification using SSR.
The only exemption are aircraft which use Mode S, those can be assigned squawk 1000 and this leads to a correlation of flight plan data using the callsign transmited by the transponder instead of the squawk itself.