+ 1
why default must be at the end of cases? i changed its place with a case and program worked correct..
10 Respuestas
+ 1
Yes you have right and in comments its make noted from much time but not change its maded
+ 4
The default option was meant as the last resort where other conditions doesn't meet the criteria, or an option to deal with the unthinkable, "when all else fails take the default path".
+ 4
the compiler checks all casses and if all of them refused the defult will be executed.
no matter where the default is .
i read this at book C programming language by Hiedeh Aliabadi.
+ 2
default case must not be last case... Its usually placed at last for make statements more readable
+ 2
It doesn't. The compiler turns it into the same thing. Putting the default case at the end is just a style choice.
+ 2
While that sentence is technically wrong, it's not a bad idea to keep it at the end for readability.
+ 1
got it... thank you.
but can we tell sololearn to correct this?
+ 1
Where SL say this?
+ 1
Go to Learn part of app, C++ tutorial, Conditionals and Loops, The switch statement, at the bottom of page 7 (The default case) you can see this sentence as a note..
0
"The default case must appear at the end of the switch."
but this is the sentence in note..