Bird
0
0

Why does continue inside nested loops only affect the innermost loop in bash?

hard🧠 Conceptual Q10 of 15
Bash Scripting - Loops
Why does continue inside nested loops only affect the innermost loop in bash?
ABecause continue exits all loops immediately
BBecause continue only skips the current iteration of the loop where it is called
CBecause continue restarts the outer loop
DBecause continue pauses the script until user input
Step-by-Step Solution
Solution:
  1. Step 1: Understand continue behavior in nested loops

    Continue affects only the loop where it is executed, skipping its current iteration.
  2. Step 2: Explain why outer loops are unaffected

    Outer loops continue normally because continue does not propagate beyond the current loop.
  3. Final Answer:

    Because continue only skips the current iteration of the loop where it is called -> Option B
  4. Quick Check:

    Continue affects only current loop = B [OK]
Quick Trick: Continue skips only innermost loop iteration [OK]
Common Mistakes:
MISTAKES
  • Thinking continue exits all loops
  • Assuming continue restarts outer loops
  • Confusing continue with break

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes