+ 4
What's wrong with this code?
Please explain why this code run operators in all cases and default? In fact switch shoud run operators only in one case or in default if there no coincidence with cases, or I don't know something about switch? https://code.sololearn.com/ci7pq1MpAOqM/?ref=app
3 Answers
+ 11
you need to add a break statement between each case otherwise the code will execute from the first true condition and fall through to the other cases
0
you have to add a break statement in each case.