The Question : What will be the value of rem after the execution of the following code snippet? Give reason.code =2;switch(code){ case 1: rem= 8;case 2: rem= 9;case 3: rem= 10; breakcase 4: rem= 11; break;}
Solution for the question :
rem=10
case 2 will be executed and rem will become 9 but because of absence of break statement the control will move down(fall through) and case 3 will be executed which will make rem as 10 now break will terminate the switch case statement.
The correct answer to the question is researched by our moderators and shared with you. You can give feedback by commenting for the answers you think are wrong.