Why does this program not output 20?
#include<stdio.h>
int main() {
int a = 1;
switch (a) {
int b = 20;
case 1:
{
printf("b is %d\n", b);
break;
}
default:
{
printf("b is %d\n", b);
break;
}
}
return 0;
}
Because the switch statement jumps to a relevant case, so the line int b = 20
will never be executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With