+ 1
Why is switch used and is alternate method for what?
2 Respostas
+ 3
switch is used as alternate method for multi if. Instead of write :
if (a==onevalue)......
else if (a==othervalue) ,,,
else if (a==otherothervalue)...
...............................................
you can write one switch command with a several case branches..
+ 2
switch is a multi conditional statement
it can be used when we want to avoid the multiple use of too many if statements
we can also use continue statement with it which is not allowed with if