Recently I replaced the altitude encoder in my airplane because ATC could not receive my altitude during VFR flight following. Up to that point I had been flying VFR under the class B shelf for some time, and I assume my transponder wasn't transmitting the altitude to ATC. It may have been non-functional for several months. Was I causing panic in the control tower because my plane wasn't reporting the altitude, and I wasn't on any ATC frequencies for them to contact me? Can ATC determine my altitude from their ground based radar? Is ATC able to contact VFR airplanes when their transponders/encoders are off, or tuned to the wrong squawk code, or malfunctioning? The transponder is tested every two years, so that is a lot of time for something to go wrong.
A lot of this has to do with whether or not you're talking to ATC.
If you're talking to ATC and your Mode C disappears or goes insane they'll ask you to report your altitude (and if your Mode C altitude reporting is wildly off they'll probably tell you something like "Stop altitude squawk - altitude differs by 500 feet". This is your cue to take the plane to an avionics shop and have the system checked/serviced, and not to attempt to enter B or C airspace, or fly above 10,000MSL, until its fixed.
In most cases ATC will continue to work you in the system until you are clear of the Mode C veil (possibly expediting your exit if having no altitude readout on your target is messing up their day) because it's better to be talking to you than not.
If you're not talking to ATC things get a bit more complex:
If your Mode C altitude readout is missing ATC will generally report you as "traffic, altitude unknown" to other aircraft and apply lateral separation exclusively (nobody is allowed within the minimum lateral separation distance of your target unless they have you in sight and can maintain visual separation). If/When other pilots spot you ATC will usually ask them for your type and altitude so they have some idea of who you are and what you're doing.
If your encoder or transponder is malfunctioning and reporting an incorrect altitude that's substantially more dangerous: ATC has no way of verifying your altitude other than asking you (or another pilot), so they'll be maintaining separation based on an incorrect altitude. This is why even VFR aircraft equipped with Mode C need an encoder check.
In this case ATC will find out about a malfunction when you're called as traffic to someone and they respond with "Is that my traffic above/below me?"