Open in TheBrain

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.

  1. Implement a Y-controlled loop with prompt/read inside the body; explain sentinel input and test termination.
  2. Implement while counter from 0 to 10; explain initialization, condition, increment, and output order.
  3. Implement until counter from 0 to 25; compare the condition with the while loop.
  4. Build the date-guess loop using date +%a, variable capture, read, and repeat-until-correct. Note daily/locale-dependent expected value.
  5. Trace the source pattern that echoes x then increments until 10. Explain why 10 may not appear.
  6. Write even-count, countdown, and tripling loops as assigned. State boundary inclusivity and verify sequence.
  7. For each, identify an error that could prevent termination and how to inspect it.

Reflection: How does user input control the next condition check?