Bird
0
0

Which control flow statement in PowerShell allows repeating a block of code while a condition is true?

easy📝 Conceptual Q2 of 15
PowerShell - Control Flow
Which control flow statement in PowerShell allows repeating a block of code while a condition is true?
Aif statement
Bwhile loop
Ctry-catch block
Dswitch statement
Step-by-Step Solution
Solution:
  1. Step 1: Identify looping statements

    PowerShell uses loops like 'while' and 'for' to repeat code blocks.
  2. Step 2: Match the statement to repeating while condition true

    'while' loop repeats as long as its condition remains true, unlike 'if' or 'switch'.
  3. Final Answer:

    while loop -> Option B
  4. Quick Check:

    Loop for condition true = while loop [OK]
Quick Trick: Use while to repeat code while condition holds [OK]
Common Mistakes:
  • Confusing if with loops
  • Thinking switch repeats code
  • Mixing try-catch with loops

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes