Bird
0
0

Which of the following is the correct syntax to return a value from a PowerShell function named Get-Number?

easy📝 Syntax Q3 of 15
PowerShell - Functions
Which of the following is the correct syntax to return a value from a PowerShell function named Get-Number?
Areturn(5)
Breturn 5
Creturn 5;
Dreturn: 5
Step-by-Step Solution
Solution:
  1. Step 1: Review PowerShell return syntax

    PowerShell uses 'return' followed by a space and the value to return, no parentheses or special characters needed.
  2. Step 2: Check each option

    return 5 is correct syntax. return(5) has unnecessary parentheses, C has an unnecessary semicolon, D uses invalid colon syntax.
  3. Final Answer:

    return 5 -> Option B
  4. Quick Check:

    Correct return syntax = 'return value' [OK]
Quick Trick: Use 'return value' without parentheses or colons [OK]
Common Mistakes:
  • Adding parentheses around return value
  • Using semicolons at end of return
  • Using colon after return keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes