How can i use break statement in if else without using any loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can i use break statement in if else without using any loop

6th Jul 2020, 9:33 AM
Rajat Sahu
Rajat Sahu - avatar
4 Answers
+ 2
Break is only in loops. You can make your condition stricter in if/else to avoid them all working. Show your code and I'll try and give an example
6th Jul 2020, 9:38 AM
Olivia
Olivia - avatar
+ 2
Because your else isn't attached to anything. The if without braces only encompasses the single statement that immediately follows it.
6th Jul 2020, 9:40 AM
تركي منصور الحمياني
 تركي منصور الحمياني  - avatar
0
It will only execute only one or none of those blocks.,but why don't you try it? and see nothing happened. it is completely waste
6th Jul 2020, 11:37 AM
Super Programmer
Super Programmer - avatar
- 1
Did you mean how to use `break` in a `switch` statement?
6th Jul 2020, 11:05 AM
Ipang