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.
- Implement the
carryon=Ysentinel loop; prompt and read each pass. Test Y twice, then a non-Y value. Explain condition rechecking. - Write
whilecounter to 10 anduntilcounter to 25. Trace comparison values at first and last tests. - Create weekday guess loop using command substitution from
date +%a; discuss uppercase/case and locale. - Analyze the 0-to-10 echo-before-increment example and write a trace table.
- Count from 0 to 20 by twos and from 100 down to 0; ensure endpoints included and explain update direction.
- Write a tripling loop to 243, then adjust start value on paper and explain how sequence changes.
- 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?