Bird
0
0

What is the output of this Swift code?

medium📝 Predict Output Q13 of 15
Swift - Functions
What is the output of this Swift code?
func multiply(_ a: Int, _ b: Int) -> Int {
    return a * b
}

print(multiply(3, 4))
A12
Bmultiply(3, 4)
CError: Missing argument labels
D7
Step-by-Step Solution
Solution:
  1. Step 1: Understand function parameters with underscore

    Both parameters have underscores, so argument labels are omitted when calling.
  2. Step 2: Calculate the function result

    Calling multiply(3, 4) returns 3 * 4 = 12, which is printed.
  3. Final Answer:

    12 -> Option A
  4. Quick Check:

    3 * 4 = 12 [OK]
Quick Trick: Underscore means call without labels, so multiply(3,4) works [OK]
Common Mistakes:
  • Expecting argument labels in call
  • Confusing output with string of function call
  • Adding parameters incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes