Bird
0
0

What is the output of this PowerShell code?

medium📝 Command Output Q4 of 15
PowerShell - Operators
What is the output of this PowerShell code?
$x = 15
$y = 4
$z = $x % $y
Write-Output $z
A3
B4
C11
D0
Step-by-Step Solution
Solution:
  1. Step 1: Calculate the remainder of 15 divided by 4

    15 divided by 4 is 3 remainder 3, so 15 % 4 equals 3.
  2. Step 2: Confirm output of Write-Output

    Write-Output prints the value of $z, which is 3.
  3. Final Answer:

    3 -> Option A
  4. Quick Check:

    Modulo operator % output = 3 [OK]
Quick Trick: Use % to get remainder after division [OK]
Common Mistakes:
  • Confusing % with /
  • Expecting quotient instead of remainder
  • Using * instead of %

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes