Bird
0
0

What is the output of this PowerShell command?

medium📝 Command Output Q13 of 15
PowerShell - String Operations
What is the output of this PowerShell command?
$num = 7.12345
"Rounded number: {0:N2}" -f $num
ARounded number: 7
BRounded number: 7.12345
CRounded number: 7.12
DRounded number: 7.1
Step-by-Step Solution
Solution:
  1. Step 1: Understand the format specifier N2

    The format specifier 'N2' means number with 2 decimal places, rounding the value.
  2. Step 2: Apply formatting to the number

    $num = 7.12345 rounded to 2 decimals is 7.12, so the output string is "Rounded number: 7.12".
  3. Final Answer:

    Rounded number: 7.12 -> Option C
  4. Quick Check:

    Number format N2 rounds to 2 decimals = D [OK]
Quick Trick: N2 means number with 2 decimals, rounds automatically [OK]
Common Mistakes:
  • Ignoring rounding and printing full decimals
  • Confusing N2 with other formats
  • Missing the decimal places

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes