Practice Lab 11.14
Practice Lab 11.14 — Loop Conditions and Arithmetic Sequences
Name: Date:
Instructions
Complete this integrated practice using Bash. Before running, write the condition and update in plain language. Record actual output and trace values.
- Create a user-controlled loop that repeats while input is
Y; demonstrate two repeats then exit. Explain sentinel behavior. - Write
whilecounter from 0 to 10 anduntilfrom 0 to 25; annotate condition logic and update. - Create weekday guessing script from current abbreviated date. Explain
datesubstitution and why response may be locale-sensitive. - Compare print-before-increment and increment-before-print counters using a small range; explain output differences.
- Write loops for even numbers 0–20 and countdown 100–0. Show initial, condition, update, output order.
- Write repeated multiplication sequence ending at 243; explain why choosing a starting value matters.
- Identify a possible infinite-loop bug in a sample update/condition of your choice and explain correction without executing it.
- Summarize
whileversusuntil, counter loops versus user-controlled loops.
Reflection: Which sequence was most vulnerable to skipping its stopping value?