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 > 10) { }
Bif ($a -gt 10) { }
Cif ($a gt 10) { }
Dif ($a => 10) { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall PowerShell comparison syntax

    PowerShell uses operators with a dash, like -gt for greater than, not symbols like > or =>.
  2. Step 2: Identify the correct operator for greater than

    The correct operator is -gt, so the syntax is if ($a -gt 10) { }.
  3. Final Answer:

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

    Greater than operator = -gt [OK]
Quick Trick: Use dash before comparison operators in PowerShell [OK]
Common Mistakes:
  • Using > instead of -gt
  • Writing 'gt' without dash
  • Using invalid operator =>

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes