Bird
0
0

Which Swift type is best to store the number 42 without any decimal part?

easy📝 Conceptual Q11 of 15
Swift - Data Types

Which Swift type is best to store the number 42 without any decimal part?

AString
BDouble
CFloat
DInt
Step-by-Step Solution
Solution:
  1. Step 1: Understand the number type

    The number 42 is a whole number without decimals.
  2. Step 2: Match with Swift types

    Int stores whole numbers, while Double and Float store decimal numbers.
  3. Final Answer:

    Int -> Option D
  4. Quick Check:

    Whole number = Int [OK]
Quick Trick: Whole numbers use Int, decimals use Double or Float [OK]
Common Mistakes:
  • Choosing Double or Float for whole numbers
  • Confusing String with number types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes