what if I don't use break; in Switch? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what if I don't use break; in Switch?

without using break; code works properly, so why should I use break? And what is it importance? I need a good explaination ☺

23rd Apr 2018, 11:48 AM
RH Tasin
RH Tasin - avatar
4 Answers
+ 2
Donna Will you add something concrete in the default statement so Tasin sees that the statement in default is executed as well? ☺
23rd Apr 2018, 12:08 PM
cyk
cyk - avatar
+ 1
Hi Gordie It seems to me your are not on sololearn to learn coding. But you have a lot of knowledge about coding. can you tell me where do you learn coding?
23rd Apr 2018, 1:20 PM
RH Tasin
RH Tasin - avatar
+ 1
well Gordie, you are very helpful. It would be a great pleasure if I counld connect with you privetly through facebook or whatsapp.
24th Apr 2018, 1:14 AM
RH Tasin
RH Tasin - avatar
0
The code keeps going and compares the value with the next case. If it finds a match it executes it. But it is considered a waste of time since you already found your answer why bother looking at rest of the code to slow down the program.
23rd Apr 2018, 12:28 PM
Akib
Akib - avatar