0

Why do we need break many times in switch statements

28th Feb 2017, 12:45 AM
Serjeel Ranjan
Serjeel Ranjan - avatar
4 Respostas
+ 8
break; represents the end of every case. So, a break; statement is used at the end of every 'case'. If you don't use break; at the end of a 'case', the next 'case' will also be executed.
28th Feb 2017, 1:39 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
Break after each case so you dont get all the cases printed to the screen.
28th Feb 2017, 1:52 AM
JP Soft Dev
JP Soft Dev - avatar
+ 1
In order to avoid fall through condition. Because if we don't use break the program will terminate each and every case in one go.
1st Mar 2017, 11:03 AM
Neha
Neha - avatar
0
umm. to make code work?
6th Mar 2017, 12:59 AM
diogo