I think they are both similar, but I do find that the if, else if, else statements are common with other programming languages like python. Therefore fore simplicity’s sake, I would probably go with the if statements. However, switch does help you avoid so many curly brackets, so there are some advantages. Visual Studios, thankfully, points out your errors and suggests ways to fix them, which I find to be really useful. Plus it appears you can still imbed variables in the case statements.
Great explanation!
I Would definitely agree. Although I would use Switch statements more often for their readability and how clean it looks. But agree both do the function.
I’ve always wondered why many programming courses are a bit unsure on switch/case statements. I’ve always found them immensly useful when planning out multiple lines of execution.
Even turbo Pascal had case/switch statements, its rather odd that some languages might not. I’m not even sure the processing overhead for switch compared to if is that different. if anything, i’d have thought switch was more efficient.
Although they both are same (if and switch statement) I also like to work with if statement as it is common in many other language also and even a bit easier to understand code