+ 1

Need of break in switch case

In the switch case,what is the need of break because the value which is given in the condition, it should execute only that value.why does it execute and print all the cases??

22nd Jul 2017, 11:23 AM
Justin P Mathew
3 Answers
+ 9
pretty sure so you can perform fallthrough cases like so switch(value) { case 1: case 2: cout << "value is 1 or 2" << endl; break; case 3: case 4: cout << "value is 3 or 4" << endl; break; }
22nd Jul 2017, 11:28 AM
jay
jay - avatar
22nd Jul 2017, 11:33 AM
Saumya
Saumya - avatar
+ 1
because skip the other cases
22nd Jul 2017, 12:07 PM
ch.chitti srilakshmi
ch.chitti srilakshmi - avatar