0
Why do we use default statement in switch cases?
5 Answers
+ 1
ohh okay okay. I get it. it's for the situation where all the given condition goes false, isn't it?
+ 1
in case if none of cases were match
+ 1
Well, just for fun let us assume that the default statement ain't there and you have only the case statements. What if they all turn out false!! What is the compiler to do now..... Thus you have an error or a bug in your program. It is to avoid this you use a default statement.
0
if none of the case is satisfied then the default case is displayed
0
That's true.