Bird
0
0

Which of the following is the correct way to create a variable named age with the value 30 in PowerShell?

easy📝 Syntax Q12 of 15
PowerShell - Variables and Data Types
Which of the following is the correct way to create a variable named age with the value 30 in PowerShell?
A$age = 30
Bset age = 30
Cage = 30
Dvar $age = 30
Step-by-Step Solution
Solution:
  1. Step 1: Recall PowerShell variable syntax

    Variables start with $ and assignment uses =.
  2. Step 2: Check each option

    $age = 30 uses $age = 30, which is correct syntax for variable creation and assignment.
  3. Final Answer:

    $age = 30 -> Option A
  4. Quick Check:

    Variable = $name = value [OK]
Quick Trick: Always start variable names with $ in PowerShell [OK]
Common Mistakes:
  • Omitting the $ before variable name
  • Using 'set' keyword which is not PowerShell syntax
  • Adding 'var' keyword which is not used in PowerShell

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes