Bird
0
0

You want to calculate the average of three numbers: 10, 20, and 30 in PowerShell. Which code correctly does this?

hard📝 Application Q8 of 15
PowerShell - Operators
You want to calculate the average of three numbers: 10, 20, and 30 in PowerShell. Which code correctly does this?
A$avg = (10 + 20 + 30) * 3
B$avg = 10 + 20 + 30 / 3
C$avg = 10 * 20 * 30 / 3
D$avg = (10 + 20 + 30) / 3
Step-by-Step Solution
Solution:
  1. Step 1: Sum the numbers inside parentheses

    10 + 20 + 30 = 60.
  2. Step 2: Divide the sum by 3 to get average

    60 / 3 = 20.
  3. Final Answer:

    $avg = (10 + 20 + 30) / 3 -> Option D
  4. Quick Check:

    Parentheses ensure correct sum before division [OK]
Quick Trick: Use parentheses to sum before dividing for average [OK]
Common Mistakes:
  • Missing parentheses causing wrong order
  • Multiplying instead of dividing
  • Dividing only last number

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes