Bird
0
0

What will be the output of this Swift code?

medium📝 Predict Output Q5 of 15
Swift - Data Types

What will be the output of this Swift code?

let a: Float = 2.5
let b: Float = 1.5
let c = a * b
print(c)
A3.75
B3.7
C4.0
DError: Cannot multiply Float values
Step-by-Step Solution
Solution:
  1. Step 1: Multiply two Float values

    2.5 * 1.5 equals 3.75 as Float multiplication.
  2. Step 2: Print the result

    Print outputs 3.75 as expected.
  3. Final Answer:

    3.75 -> Option A
  4. Quick Check:

    Float multiplication = 3.75 [OK]
Quick Trick: Float multiplication works like normal math [OK]
Common Mistakes:
  • Rounding result incorrectly
  • Expecting error on Float multiply
  • Confusing Float with Int

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes