Bird
0
0

Which of the following is true about the condition in a repeat-while loop?

easy📝 Conceptual Q2 of 15
Swift - Loops
Which of the following is true about the condition in a repeat-while loop?
AThe condition is evaluated before the loop body executes.
BThe condition is evaluated after the loop body executes.
CThe condition must always be true to avoid errors.
DThe condition cannot use variables.
Step-by-Step Solution
Solution:
  1. Step 1: Identify when the condition is checked

    In a repeat-while loop, the condition is checked after the loop body runs.
  2. Step 2: Understand implications

    This means the loop runs at least once regardless of the condition's initial value.
  3. Final Answer:

    The condition is evaluated after the loop body executes. -> Option B
  4. Quick Check:

    Condition check timing = after loop body [OK]
Quick Trick: Condition in repeat-while is checked after loop body runs [OK]
Common Mistakes:
  • Assuming condition is checked first
  • Believing condition must be true initially
  • Thinking variables can't be used in condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes