Practice Lab 11.9
Practice Lab 11.9 — While, Until, and Sequence Practice
Name: Date:
Instructions
Use the course Bash environment. Write full scripts and explain each. Use trace tables and test modest bounds first; avoid infinite-loop mistakes.
- Build the user-controlled
Yrepeat loop. Show how a new read value is tested on the next pass. - Build a
whileincrementing counter from 0 through 10; record values at condition, output, update. - Build an
untilcounter through 25; compare truth conditions and termination. - Build the date guessing loop using abbreviated weekday; record date/locale and explain why fixed sample output isn’t expected.
- Trace an echo-then-increment loop and explain the last printed value.
- Design/run 0-to-20-by-2, 100-to-0 countdown, and tripling-to-243 loops. Explain endpoint choices.
- For each loop identify a possible off-by-one or nontermination error and the correction in your own words.
Reflection: Which variable update guarantees progress in each numeric sequence?