Bird
0
0

Identify the error in the following Swift function declaration:

medium📝 Debug Q14 of 15
Swift - Functions
Identify the error in the following Swift function declaration:
func multiply(a: Int, b Int) -> Int {
    return a * b
}
AMissing colon between parameter name and type for b
BMissing return keyword
CFunction name is invalid
DReturn type should be String
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter syntax

    Each parameter must have a colon between its name and type. Here, b Int is missing a colon.
  2. Step 2: Confirm other parts are correct

    The return keyword is present, function name is valid, and return type Int is appropriate.
  3. Final Answer:

    Missing colon between parameter name and type for b -> Option A
  4. Quick Check:

    Parameters need colon between name and type [OK]
Quick Trick: Check colons between parameter names and types [OK]
Common Mistakes:
  • Omitting colon in parameter list
  • Forgetting return keyword
  • Using wrong return type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes