Can switch case be used within an if else statement? If so can someone please give an example with the proper syntax?

10/17/2019 6:44:56 AM


4 Answers

New Answer


Yes it can. You can try it yourself on code playground.


Why is the question "can"? Why can't you just try it out? Why is there a hesitation in trying out things, I am sure you know the syntax of switch-case. All you need is a little bit of imagination and logic. In the course you have seen the use of switch-case in the main directly, all you have to do is to move the whole code in if-else and you are done !


What are you mean?


Hello everyone, just here to let you guys know that i did try it myself but the problem is that the if statement is being executed irrespective of whether the condition was true or false. So it'd be very nice if someone could write an example code for me. Thankyou for your time