Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q13 of 15
PowerShell - Variables and Data Types
What will be the output of this PowerShell code?
$a = 7
$b = 2
$c = $a / $b
Write-Output $c
A3
B3.5
C3.0
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand division with integers in PowerShell

    PowerShell automatically converts to floating-point when dividing integers if result is not whole.
  2. Step 2: Calculate 7 divided by 2

    7 / 2 = 3.5, a floating-point number.
  3. Final Answer:

    3.5 -> Option B
  4. Quick Check:

    Integer division returns float if needed = 3.5 [OK]
Quick Trick: Division returns float if not exact integer [OK]
Common Mistakes:
  • Expecting integer truncation
  • Thinking division causes error
  • Confusing 3.0 with 3.5

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes