Bird
0
0

Which of the following is the correct way to write the number ten million (10,000,000) in Swift using underscores for readability?

hard📝 Application Q8 of 15
Swift - Data Types
Which of the following is the correct way to write the number ten million (10,000,000) in Swift using underscores for readability?
Alet number = 100_00000
Blet number = 1_0000_000
Clet number = 10000_000
Dlet number = 10_000_000
Step-by-Step Solution
Solution:
  1. Step 1: Understand underscore usage

    Swift allows underscores anywhere between digits to improve readability, but they must separate groups of digits logically.
  2. Step 2: Analyze each option

    let number = 10_000_000 correctly groups digits as 10_000_000, which is standard for ten million.
    Options B, C, and D have irregular groupings that do not represent the number correctly.
  3. Final Answer:

    let number = 10_000_000 -> Option D
  4. Quick Check:

    Underscores separate digit groups logically [OK]
Quick Trick: Use underscores to separate digits in groups of three [OK]
Common Mistakes:
  • Placing underscores in inconsistent or invalid positions
  • Grouping digits incorrectly leading to wrong values
  • Assuming underscores affect the numeric value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes