0

What will be happen if not put break statement in switch case?

Any guess

7th May 2019, 12:48 PM
Vijith Krishnan S
Vijith Krishnan S - avatar
6 Respuestas
+ 4
Let's says you have 3 stages in your switch case;without break if first condition fits all these 3 stages will performed. But you use switch to do specific action for specific conditions so when programme see this it should do and break out from switch. the example below is just for you to understand typo depends on language switch grade: case a: print "excellent"; break: case b: print "good work"; break: case c: print "better next time"; break: case d: print "not bad"; break: case e: print "work harder"; break: default: print "failed"; if you don't use break it will display all messages. https://code.sololearn.com/cpYJQ8X6J0Y6/?ref=app
7th May 2019, 1:06 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar
7th May 2019, 2:44 PM
Noverdi Ramadhan
Noverdi Ramadhan - avatar
+ 2
Without break statement if any condition is satisfied then all the statement below it will also be printed on screen.
9th May 2019, 2:36 AM
Madhav Kotnala
Madhav Kotnala - avatar
+ 2
Stack overflow - infinite loop 😡
9th May 2019, 10:28 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
If we don't use break statement in switch case then fall through ocuurs And entire program get executed Until compiler finds break statement
29th May 2019, 8:06 AM
Sudeep Saurav
Sudeep Saurav - avatar
- 1
Sanjay Kamath by switch you can not have infinite loop
15th May 2019, 12:10 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar