20 February 2015 20 6K Report

In a switch construct, why doesn't the compiler show any error and skips the statements written within the cases like for example I write printf("hello"); in between case 1 and case 2, so why is there no error in this and how come the compiler skips this step?

For example I write

case 1: int a=9; break;

printf("hellooo");

case 2 : int y =98;

printf("kill");

break;

So here when parsing is done either the compiler should throw any error because of the printf statement or it must print the statement which is written between the two cases but it skips it. Why does it happen?

Similar questions and discussions