Worked Examples · Example 4.6
Q.Let us write a pseudocode and draw a flowchart where multiple conditions are checked to categorise a person as either child (<13), teenager (>=13 but <20) or adult (>=20), based on age specified.
Sikkim CbseNCERTSubjective· 3mImportance★★★★★est
31% · 11/36 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Three mutually exclusive age ranges are handled by chained (cascading) conditions: test "age < 13" first, then "age < 20", and let everything else fall through to "Adult".
The idea. When a problem has more than two outcomes, we chain decisions: each ELSE holds the next IF. Because the tests run in order, the second test age < 20 only ever sees ages that are already ≥ 13 — so it correctly captures "13 or more but under 20" without writing the compound condition explicitly. This ordering trick keeps multi-way selection simple.
Pseudocode:
Step 1: INPUT age
Step 2: IF age < 13 THEN
PRINT "Child"
ELSE IF age < 20 THEN
PRINT "Teenager"
ELSE
PRINT "Adult"
Step 3: STOP
Flowchart (nodes and arrows):
- Start (oval)
- ↓ Input age (parallelogram)
- ↓ Decision (diamond): "age < 13?"
- Yes → Output "Child" → Stop
- No → step 4
- ↓ Decision (diamond): "age < 20?"
- Yes → Output "Teenager" → Stop
- No → Output "Adult" → Stop
- Stop (oval)
Python implementation:
age = int(input("Enter age: "))
if age < 13:
print("Child")
elif age < 20:
print("Teenager")
else: …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.