Bird
0
0

What will this PowerShell script output?

medium📝 Command Output Q5 of 15
PowerShell - Variables and Data Types
What will this PowerShell script output?
$x = 5
$y = 10
$z = $x + $y
Write-Output $z
A5 + 10
B$x + $y
C15
DError: Cannot add variables
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable arithmetic in PowerShell

    Variables holding numbers can be added using the + operator.
  2. Step 2: Calculate the sum

    $x is 5 and $y is 10, so $z becomes 15, which is printed.
  3. Final Answer:

    15 -> Option C
  4. Quick Check:

    Numeric variables can be added directly [OK]
Quick Trick: Use + to add numeric variables [OK]
Common Mistakes:
  • Expecting string concatenation without quotes
  • Thinking variables print as names
  • Assuming addition causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes