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.
- Write sentinel-controlled
whileloop withcarryon=Y, message, prompt/read, and final exit message. Test several inputs. - Write counter loop using
whileto 10; explain each line and trace values. - Write
untilcounter to 25; explain difference and compare output. - Capture weekday from
date +%a; create guessing loop and describe locale/time dependence. - Explain print-before-increment loop and its output boundary.
- 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.
- Change step size or start value in one loop; predict whether endpoint is reached and explain.
- 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?