#include<stdio.h>
int main()
{
int n=0, i=2;
switch(1)
{
case 0:do
{
case 1: n++;
case 2: n++;
}while(--i > 0);
}
printf("n = %d",n);
}
I was expecting output for above code to be 0, as case 1 and case 2 are inside a do while which is inside case 0. Switch is testing on value 1, so case 0 will never be executed and hence neither case 1 or 2.
value of n coming to be 4. Any explanation ?