How can you use a Kotlin for loop with ranges to print the multiplication table of 3 from 3 to 30?
hard📝 Application Q9 of 15
Kotlin - Loops and Ranges
How can you use a Kotlin for loop with ranges to print the multiplication table of 3 from 3 to 30?
Afor (i in 3..30 step 3) { println(i) }
Bfor (i in 1..10) { println(i * 3) }
Cfor (i in 3..30) { if (i % 3 == 0) println(i) }
DAll of the above
Step-by-Step Solution
Solution:
Step 1: Understand each approach
for (i in 3..30 step 3) { println(i) } uses step 3 from 3 to 30, printing multiples of 3. for (i in 1..10) { println(i * 3) } multiplies loop variable by 3 from 1 to 10. for (i in 3..30) { if (i % 3 == 0) println(i) } checks multiples of 3 in 3 to 30.
Step 2: Verify all print the multiplication table of 3
All options print 3,6,9,...30 correctly.
Final Answer:
All of the above -> Option D
Quick Check:
Multiple ways to print multiplication table = B [OK]
Quick Trick:Use step, multiplication, or condition for tables [OK]
Common Mistakes:
MISTAKES
Using wrong step size
Looping incorrect range
Missing condition for multiples
Master "Loops and Ranges" in Kotlin
9 interactive learning modes - each teaches the same concept differently