Bird
0
0

What will be the output when running this code in Swift Playgrounds?

medium📝 Predict Output Q4 of 15
Swift - Basics and Runtime
What will be the output when running this code in Swift Playgrounds?
let a = 3
let b = 4
print(a * b)
A7
B34
C12
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand the code operations

    Variables a and b are assigned 3 and 4. The print statement multiplies them: 3 * 4.
  2. Step 2: Calculate the multiplication

    3 times 4 equals 12, so print outputs 12.
  3. Final Answer:

    12 -> Option C
  4. Quick Check:

    Multiplication output = 12 [OK]
Quick Trick: Multiplying numbers prints their product [OK]
Common Mistakes:
  • Adding instead of multiplying
  • Concatenating numbers as strings
  • Expecting syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes