Chapter 4: Problem 36
Sometimes either a switch statement or an if/else if statement can be used to implement logic that requires branching to different blocks of program code. But the two are not interchangeable. A) Under what circumstances would an if/else if statement be a more appropriate choice than a switch statement? B) Under what circumstances would a switch statement be a more appropriate choice than an if/else if statement? C) Under what circumstances would a set of nested if / else statements be more appropriate than either of the other two structures? Try to come up with at least one example case for each of the three, where it is the best way to implement the desired branching logic.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.