There is another conditional known as switch..case. switch..case basically acts like a switchboard, as in it checks the input against predefined cases and if the input matches any case, then the code mentioned against that particular case is executed.
Let’s try to understand the switch..case in detail.
You learnt about the switch statement and understood that it’s contemporary for if/else. Let’s try to understand this in the context of the question you were solving in the last segment, finding whether a number is negative or positive or zero.
You just learnt that if a condition involves evaluating ranges, for example, x > 0 or x < 45, there is no corresponding case in a switch statement because the range contains infinite cases and all these cases cannot be defined in switch..case.