Practice Lab 11.11
Practice Lab 11.11 — Expanded Loop Boundary Practice
Name: Date:
Instructions
Use Bash and the class shell. Complete the full worksheet; practice each loop pattern and record traces. Do not execute a loop that you suspect will not terminate.
- Create the
Ysentinel loop. Test uppercase Y, then a stopping value; explain comparison and next read. - Write a counter
whileto 10 and anuntilto 25. Trace first/last tests and compare conditions. - Capture current weekday with
date +%a; create guessing loop. Explain command substitution and how locale/capitalization may affect matching. - Trace print-before-update loop to 10. Then write a second version with update before output and compare predicted first/last values.
- Design 0–20 by 2; test a start value that would skip the endpoint and explain why your condition must match step size.
- Design 100–0 countdown; ensure zero is included. Trace first, middle, last iteration.
- Design multiplication-by-three sequence ending at 243; identify starting value and exact termination criterion.
- Explain safe debugging of bad conditions/updates, and compare
whileanduntil.
Reflection: Which boundary case helped reveal an off-by-one issue?