0

In switch function how to write the number limit in the case?

If we are asked to write the age limit for a child an adult and senior citizen

28th Mar 2017, 7:52 PM
Tehreem
2 Answers
+ 4
you can do: case 1: case 2: case 3: ... case 12: cout<<"too young!"<<endl; break; but that would be too much code. use if-else instead and check for age>1 && age<12 for example.
28th Mar 2017, 9:48 PM
Mario L.
Mario L. - avatar
0
Then can't we write a program on age limit using switch function
28th Mar 2017, 8:16 PM
Tehreem