Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Read an age and say if the person is a teenager, from to years. What does it say for , and ?
a <= x <= b checks a range, with both ends included.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Plan. A range check in one line: 13 <= age <= 19.
12 >= 13 is false, so not a teenager.20 <= 19 is false, so not a teenager.Check. Both ends are included. Age 13 and age 19 are teenagers.
Log in to join the discussion.
Loading…