Bird
0
0

Identify the error in this PowerShell code:

medium📝 Debug Q6 of 15
PowerShell - Operators
Identify the error in this PowerShell code:
$num = 10
$num +== 5
Write-Output $num
AThe operator +== is invalid syntax
BVariable $num is not initialized
CWrite-Output is missing parentheses
DThe code will run without errors
Step-by-Step Solution
Solution:
  1. Step 1: Check the operator syntax

    The operator +== does not exist in PowerShell; the correct operator for addition assignment is +=.
  2. Step 2: Confirm other parts are correct

    $num is initialized and Write-Output works without parentheses, so no error there.
  3. Final Answer:

    The operator +== is invalid syntax -> Option A
  4. Quick Check:

    Use += for addition assignment, not +== [OK]
Quick Trick: Use +=, not +== for addition assignment [OK]
Common Mistakes:
  • Typing +== instead of +=
  • Assuming Write-Output needs ()
  • Not initializing variable before use

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes