Could somebody please explain why the answer is D and not B. I suspect the reason is because there is no Break. Thanks
4. What is the result of the following code?
int x=0;
switch(x)
{
case 1: printf( "One" );
case 0: printf( "Zero" );
case 2: printf( "Hello World" );
}
A. One
B. Zero
C. Hello World
D. ZeroHello World
No "break;" statements after your conditions. Also it's worth noting that the reason that "case 1:" did not execute is because it is postioned above the case that was met, if you were to change 'x' to 1 then all three would execute.