Open in TheBrain

Practice Lab 11.17

Practice Lab 11.17 — Loop Boundaries and User Input

Name: Date:

Instructions

Complete the whole loop lab in Bash. Record predictions, traces, and actual output. Use date and input values from your environment; do not expect identical transcripts.

  1. Implement the carryon=Y sentinel loop; prompt and read each pass. Test Y twice, then a non-Y value. Explain condition rechecking.
  2. Write while counter to 10 and until counter to 25. Trace comparison values at first and last tests.
  3. Create weekday guess loop using command substitution from date +%a; discuss uppercase/case and locale.
  4. Analyze the 0-to-10 echo-before-increment example and write a trace table.
  5. Count from 0 to 20 by twos and from 100 down to 0; ensure endpoints included and explain update direction.
  6. Write a tripling loop to 243, then adjust start value on paper and explain how sequence changes.
  7. List safe debugging steps for a loop that does not terminate.

Reflection: Which task depended on user input, and which depended on an arithmetic update?