Bird
0
0

Find the error in this Swift code:

medium📝 Debug Q7 of 15
Swift - Variables and Constants
Find the error in this Swift code:
let a = 5; let b = 10 print(a + b)
AMissing semicolon between 'let b = 10' and 'print(a + b)'
Bprint statement syntax is incorrect
CVariables cannot be declared with semicolons
DSemicolons must be at the end of every line
Step-by-Step Solution
Solution:
  1. Step 1: Analyze statement separation

    Two statements are on the same line: 'let b = 10' and 'print(a + b)' without a semicolon separating them.
  2. Step 2: Confirm print syntax

    print(a + b) is correct syntax and not the cause of the error.
  3. Final Answer:

    Missing semicolon between 'let b = 10' and 'print(a + b)' -> Option A
  4. Quick Check:

    Missing semicolon error = A [OK]
Quick Trick: Use semicolons to separate multiple statements on one line [OK]
Common Mistakes:
  • Assuming print syntax is wrong
  • Thinking semicolons are mandatory at line ends
  • Ignoring missing semicolon between statements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes