Bird
0
0

Which of the following is the correct syntax to check if variable $a is greater than 10 in PowerShell?

easy📝 Syntax Q12 of 15
PowerShell - Operators
Which of the following is the correct syntax to check if variable $a is greater than 10 in PowerShell?
Aif ($a -gt 10) { }
Bif ($a > 10) { }
Cif ($a -lt 10) { }
Dif ($a -eq 10) { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall PowerShell comparison syntax

    PowerShell uses -gt for greater than, not > like some other languages.
  2. Step 2: Match the correct operator

    The correct syntax to check if $a is greater than 10 is if ($a -gt 10) { }.
  3. Final Answer:

    if ($a -gt 10) { } -> Option A
  4. Quick Check:

    Greater than operator = -gt [OK]
Quick Trick: Use -gt for greater than, not > in PowerShell [OK]
Common Mistakes:
  • Using > instead of -gt
  • Confusing -lt with -gt
  • Missing parentheses in if statement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes