The first switch block in the code does nothing.
When the switch statement expression is evaluated, the source code that is present before the matching case label or default label appears will be ignored. Therefore, the βBefore caseβ statement is not printed in the program below.
int x = 2; int y = 3; int main() { switch (x) { y++; printf("Before case"); case 2: printf("In case 2"); break; } return 0; }
Output:
In case 2
source share