Bird
0
0

Which of the following is the correct Kotlin syntax to create a descending range from 10 to 1?

easy📝 Syntax Q3 of 15
Kotlin - Operators and Expressions
Which of the following is the correct Kotlin syntax to create a descending range from 10 to 1?
A10..1
B10 downTo 1
C1..10 step -1
D10..1 step 1
Step-by-Step Solution
Solution:
  1. Step 1: Understand descending ranges in Kotlin

    Kotlin uses downTo to create descending ranges.
  2. Step 2: Check options

    10..1 is invalid for descending; 10 downTo 1 is correct syntax.
  3. Final Answer:

    10 downTo 1 -> Option B
  4. Quick Check:

    Use 'downTo' for descending ranges [OK]
Quick Trick: Use 'downTo' for descending ranges [OK]
Common Mistakes:
MISTAKES
  • Using .. for descending range
  • Using negative step with .. incorrectly
  • Confusing step direction

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes