Open in TheBrain

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.

  1. Create a sentinel-controlled while loop with repeated prompt/read until input is not Y.
  2. Create while and until counters with different limits. Explain their opposite condition logic and trace final tests.
  3. Create a current-weekday guessing loop using date +%a; explain command capture and changing expected value.
  4. Demonstrate print-then-update versus update-then-print using the same counter range.
  5. 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.
  6. Verify each endpoint and identify what happens if the step skips the target.
  7. 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?