Bird
0
0

Which of the following is the correct way to declare a mutable variable named score with initial value 10 in Swift?

easy📝 Syntax Q12 of 15
Swift - Variables and Constants
Which of the following is the correct way to declare a mutable variable named score with initial value 10 in Swift?
Alet score = 10
Bvariable score = 10
Cconst score = 10
Dvar score = 10
Step-by-Step Solution
Solution:
  1. Step 1: Identify the keyword for mutable variables

    In Swift, var declares a variable that can change, so use var score = 10.
  2. Step 2: Check other options

    let creates a constant, variable and const are not valid Swift keywords.
  3. Final Answer:

    var score = 10 -> Option D
  4. Quick Check:

    Mutable variable uses var [OK]
Quick Trick: Use var for variables, let for constants [OK]
Common Mistakes:
  • Using let instead of var for mutable variables
  • Using invalid keywords like variable or const
  • Missing the equals sign

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes