Bird
0
0

Which of the following is the correct syntax to check if variable $num is less than or equal to 100 in PowerShell?

easy📝 Syntax Q3 of 15
PowerShell - Operators
Which of the following is the correct syntax to check if variable $num is less than or equal to 100 in PowerShell?
Aif ($num -le 100) {}
Bif ($num <= 100) {}
Cif ($num -lt= 100) {}
Dif ($num =< 100) {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall PowerShell comparison operators

    PowerShell uses '-le' for 'less than or equal to', not '<='.
  2. Step 2: Identify correct syntax

    'if ($num -le 100) {}' is valid; others are invalid syntax.
  3. Final Answer:

    if ($num -le 100) {} -> Option A
  4. Quick Check:

    '-le' means less or equal [OK]
Quick Trick: Use '-le' for less than or equal in PowerShell [OK]
Common Mistakes:
  • Using '<=' instead of '-le'
  • Writing '-lt=' or '=<' which are invalid
  • Confusing assignment '=' with comparison

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes