Open in TheBrain

Practice Lab 11.5

Practice Lab 11.5 — Full while/until Practice Lab

Name: Date:

Instructions

Use Bash and the course shell conventions. Trace before running. If a loop appears stuck, stop it using the instructor-approved method and inspect its condition/update. Record code, output, and explanations.

  1. Create a user-input loop that continues for Y; include prompts and read inside body. Test two repeats and a stopping response.
  2. Implement a counter loop using while, starting 0 and ending at 10. Explain each line.
  3. Implement the same count using until and end at 25. Explain why its condition reads differently.
  4. Write a weekday guessing loop based on date +%a; prompt until match. Note case/locale and explain variable assignment by command substitution.
  5. Trace print-before-increment loop and explain the visible range.
  6. Create scripts counting 0–20 by 2, 100 down to 0, and multiplying by 3 until 243. For each, record test, update, output order and why it terminates.
  7. Compare list iteration from Lab 10 with condition-controlled loops here.

Reflection: Which loop required the most careful boundary planning?