Open in TheBrain

Practice Lab 11.15

Practice Lab 11.15 — Lab 11 Comprehensive Loop Skills Check

Name: Date:

Instructions

Complete all parts in Bash and use the instructor’s shell conventions. Record code, predicted and actual output, and trace table. Verify each loop terminates; do not run a loop without checking its update.

  1. Write sentinel-controlled while loop with carryon=Y, message, prompt/read, and final exit message. Test several inputs.
  2. Write counter loop using while to 10; explain each line and trace values.
  3. Write until counter to 25; explain difference and compare output.
  4. Capture weekday from date +%a; create guessing loop and describe locale/time dependence.
  5. Explain print-before-increment loop and its output boundary.
  6. Write loops counting by twos from 0 to 20, down from 100 to 0, and multiplying by 3 to 243. For each record initialization, condition, body, update, final value, and termination proof.
  7. Change step size or start value in one loop; predict whether endpoint is reached and explain.
  8. Explain how to stop/debug an unintended nonterminating loop safely in the assigned environment.

Reflection: Which checks ensure the condition and update work together as intended?