It depends on the type of interrogation received by the transponder. If it receives a Mode A interrogation, the squawk code will be transmitted. If it receives a mode C interrogation, the altitude is transmitted.
It is important to understand that squawk code and altitude are NEVER sent together by the transponder.