Practice Lab 11.18
Practice Lab 11.18 — Full Numeric Sequence Lab
Name: Date:
Instructions
Use Bash and small, controlled loops. For every script, document initialization, condition, body, update, output order, and termination. Record predictions and results.
- Create a sentinel-controlled
whileloop with repeated prompt/read until input is notY. - Create
whileanduntilcounters with different limits. Explain their opposite condition logic and trace final tests. - Create a current-weekday guessing loop using
date +%a; explain command capture and changing expected value. - Demonstrate print-then-update versus update-then-print using the same counter range.
- Create arithmetic sequence loops: 0 to 20 by 2; 30 down to 0 by 5; multiply by 3 to 243. For each, justify boundary condition.
- Verify each endpoint and identify what happens if the step skips the target.
- Explain safe recovery from a nonterminating loop and how trace tables help diagnose it.
Reflection: Which sequence required changing the condition to match its step?