Open in TheBrain

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.

  1. Create a user-controlled loop that repeats while input is Y; demonstrate two repeats then exit. Explain sentinel behavior.
  2. Write while counter from 0 to 10 and until from 0 to 25; annotate condition logic and update.
  3. Create weekday guessing script from current abbreviated date. Explain date substitution and why response may be locale-sensitive.
  4. Compare print-before-increment and increment-before-print counters using a small range; explain output differences.
  5. Write loops for even numbers 0–20 and countdown 100–0. Show initial, condition, update, output order.
  6. Write repeated multiplication sequence ending at 243; explain why choosing a starting value matters.
  7. Identify a possible infinite-loop bug in a sample update/condition of your choice and explain correction without executing it.
  8. Summarize while versus until, counter loops versus user-controlled loops.

Reflection: Which sequence was most vulnerable to skipping its stopping value?