+ 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??
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;
}
+ 4
https://www.sololearn.com/discuss/554379/?ref=app
This would help uhđ
+ 1
because skip the other cases