What if I don’t write default in switch case?

The code is valid. If there is no default: label and none of the case labels match the “switched” value, then none of the controlled compound statement will be executed. Execution will continue from the end of the switch statement.

ISO/IEC 9899:1999, section 6.8.4.2:

[…] If no converted case constant expression matches and there is no default label, no part of the switch body is executed.

Leave a Comment