Bird
0
0

How do you correctly declare a Swift function named modify that takes an inout parameter number of type Int?

easy📝 Syntax Q3 of 15
Swift - Functions

How do you correctly declare a Swift function named modify that takes an inout parameter number of type Int?

Afunc modify(_ number: Int inout) { }
Bfunc modify(inout number: Int) { }
Cfunc modify(number: inout Int) { }
Dfunc modify(number inout: Int) { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall Swift syntax for inout

    The inout keyword appears before the parameter type.
  2. Step 2: Analyze options

    func modify(number: inout Int) { } correctly places inout before Int. Other options misuse the keyword placement.
  3. Final Answer:

    func modify(number: inout Int) { } -> Option C
  4. Quick Check:

    inout before type [OK]
Quick Trick: inout always precedes the type [OK]
Common Mistakes:
  • Placing inout before parameter name
  • Putting inout after the type
  • Using inout as a parameter label

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes