Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q5 of 15
PowerShell - Variables and Data Types
What will be the output of this PowerShell code?
$num = [int]"100"
$num += 50
Write-Output $num
A150
B10050
C50
DError
Step-by-Step Solution
Solution:
  1. Step 1: Cast string '100' to integer

    $num becomes integer 100 after casting.
  2. Step 2: Add 50 to integer 100

    Adding 50 results in 150, an integer.
  3. Final Answer:

    150 -> Option A
  4. Quick Check:

    Integer cast plus addition = 150 [OK]
Quick Trick: Casting string to int allows numeric addition [OK]
Common Mistakes:
  • Assuming string concatenation instead of addition
  • Expecting error due to casting
  • Confusing data types in addition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes