Practice Lab 11.12
Practice Lab 11.12 — Full Loop Tracing and Script Practice
Name: Date:
Instructions
Write each program in Bash in a practice area. For each, record initialization, condition, body, update, predicted output, and actual result. Use short traces first.
- Write sentinel-driven
whileloop controlled byY, with prompt and read in body. Test continuation and termination. - Write and explain counter loop using
whilefrom zero toward ten. - Write equivalent
untilloop to 25. Compare condition truth and stop point. - Write weekday guessing loop based on
date +%a; record locale/time assumptions. - Explain output from echoing a value before incrementing. Predict whether boundary is printed.
- Write even sequence 0–20, countdown 100–0, and powers of three to 243. Include trace values and terminate safely.
- Change one update step deliberately on paper; predict effect on endpoint/termination. Do not run a loop you predict is infinite.
- Explain error diagnosis using variable trace and condition check.
Reflection: What information must be in a trace table to debug a loop?