Bird
0
0

What will be the output of this Swift code?

medium📝 Predict Output Q13 of 15
Swift - Basics and Runtime
What will be the output of this Swift code?
let speed = 60
let time = 2
let distance = speed * time
print(distance)
A120
B62
CError
D60
Step-by-Step Solution
Solution:
  1. Step 1: Calculate the multiplication

    speed (60) multiplied by time (2) equals 120.
  2. Step 2: Understand print output

    The print statement outputs the value of distance, which is 120.
  3. Final Answer:

    120 -> Option A
  4. Quick Check:

    60 * 2 = 120 [OK]
Quick Trick: Multiply variables and print result [OK]
Common Mistakes:
  • Adding instead of multiplying
  • Confusing variable names
  • Expecting syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes