Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q4 of 15
PowerShell - Operators
What will be the output of this PowerShell code?
$value = 20
$value += 5
$value -= 3
Write-Output $value
A22
B18
C25
D17
Step-by-Step Solution
Solution:
  1. Step 1: Calculate after addition

    Starting with $value = 20, $value += 5 adds 5, so $value becomes 25.
  2. Step 2: Calculate after subtraction

    $value -= 3 subtracts 3, so $value becomes 22.
  3. Final Answer:

    22 -> Option A
  4. Quick Check:

    20 + 5 - 3 = 22 [OK]
Quick Trick: Apply += then -= stepwise to get final value [OK]
Common Mistakes:
  • Adding and subtracting in wrong order
  • Confusing += with -=
  • Forgetting to update variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes