Bird
0
0

Which of the following is the correct way to declare a variable that can change in Swift?

easy📝 Syntax Q12 of 15
Swift - Variables and Constants
Which of the following is the correct way to declare a variable that can change in Swift?
Avar score = 10
Bconst score = 10
Clet score = 10
Dvariable score = 10
Step-by-Step Solution
Solution:
  1. Step 1: Identify Swift syntax for variable declaration

    In Swift, var is used to declare variables that can change.
  2. Step 2: Check each option

    let score = 10 declares a constant. const score = 10 and variable score = 10 use invalid keywords. var score = 10 is correct.
  3. Final Answer:

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

    Use var for changeable values [OK]
Quick Trick: Use var for changeable values, let for fixed ones [OK]
Common Mistakes:
  • Using let instead of var for variables
  • Using non-Swift keywords like const or variable
  • Syntax errors from wrong keywords

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes