Practice Lab 11.3
Practice Lab 11.3 — Complete Loop Design Worksheet
Name: Date:
Instructions
Use Bash in a safe terminal. For every loop, list initialization, condition, body, update, and termination. Start with small values, then record actual output.
- Write and run a user-controlled
whileloop that repeats when input isY, prompts inside the loop, and ends for any other response. Explain sentinel behavior. - Write a
whilecounter from 0 to 10. Show a trace table of value at test/output/update. - Write an
untilcounter from 0 to 25. Compare with thewhileversion. - Make a weekday guessing program using
date +%a,read, and a loop until correct. Record locale and current abbreviated weekday; explain variability. - Analyze a loop that outputs counter before incrementing to 10. State what appears and why output order matters.
- Design and run three sequences: even numbers 0–20, countdown 100–0, and powers of three ending at 243. Include endpoint reasoning and ensure termination.
- Explain how to detect a loop that cannot terminate and what to check before execution.
Reflection: What is the condition polarity difference between while and until?