Most programming languages, including C++, do not allow ranges of values for case like structures. Consider this flowcharting example that used ranges:
Consider also the following pseudocode for the same logic:
Case of age 0 to 17 Display "You can't vote." 18 to 64 Display "You're in your working years." 65 + Display "You should be retired."Endcase
Using the case control structure when using non integer family or ranges of values is allowed when designing a program and documenting that design with pseudocode or fowcharting. However, the implementation in most languages would follow a nested if then else approach with complex Boolean expressions. The logic of the above examples would look like this:
if age > 0 and age <= to 17 display You can't vote.else if age is >= 18 and age <= 64 display You're in your working years.else display You should be retired.