
116 Programming and Data Structures
Explanation In the above-mentioned program the outer switch counts only the spaces in a given
text. For other spaces inner switch statement is used. The inner switch is for counting Is, Os, and
others. The string length is printed at the end of the program, which is the addition of all the counts.
5.10 THE switch () CASE AND NESTED IFS
switch () case
nested ifs
The switch () can only test for equality
i.e. only constant values are applicable.
The if can evaluate relational or logical
expressions.
No two case statements have identical
constants in the same switch.
Same conditions may be repeated for
number ...