Practice Lab 11.7
Practice Lab 11.7 — Complete Counter and Input Loops
Name: Date:
Instructions
Use Bash; write and run scripts in a practice folder. Include a trace table and explain output. Use short tests before larger loops.
- Implement a
Y-controlled loop with prompt/read inside the body; explain sentinel input and test termination. - Implement
whilecounter from 0 to 10; explain initialization, condition, increment, and output order. - Implement
untilcounter from 0 to 25; compare the condition with the while loop. - Build the date-guess loop using
date +%a, variable capture, read, and repeat-until-correct. Note daily/locale-dependent expected value. - Trace the source pattern that echoes x then increments until 10. Explain why 10 may not appear.
- Write even-count, countdown, and tripling loops as assigned. State boundary inclusivity and verify sequence.
- For each, identify an error that could prevent termination and how to inspect it.
Reflection: How does user input control the next condition check?