Quick links
if...else
statement provides support to control program flow. if statement make decisions based on conditions. It selects an action, if some condition is met. However, there exits situations where you want to make a decision from available choices. For example – select a laptop from available models, select a menu from available menu list etc.
switch...case
statement gives ability to make decisions from fixed available choices. Rather making decision based on conditions. Using switch
we can write a more clean and optimal code, that take decisions from available choices.