Kotlin - Loops and RangesWhat is the output of this Kotlin code?for (i in 1..3) { print(i) }A3 2 1B1 2 3CError: missing spaceD123Check Answer
Step-by-Step SolutionSolution:Step 1: Understand the loop and print functionThe loop runs from 1 to 3, printing each number without spaces or newlines.Step 2: Trace the outputPrints 1, then 2, then 3 consecutively, resulting in "123".Final Answer:123 -> Option DQuick Check:print() outputs without spaces or newlines = C [OK]Quick Trick: print() outputs inline; println() adds newline [OK]Common Mistakes:MISTAKESAssuming print adds spacesConfusing print with printlnExpecting reversed output
Master "Loops and Ranges" in Kotlin9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kotlin Quizzes Control Flow as Expressions - When expression as powerful switch - Quiz 15hard Kotlin Basics and JVM Runtime - Why Kotlin over Java - Quiz 8hard Loops and Ranges - Labeled break and continue - Quiz 5medium Loops and Ranges - For loop with step and downTo - Quiz 15hard Null Safety - Safe call operator (?.) - Quiz 12easy Null Safety - Safe call operator (?.) - Quiz 2easy Null Safety - Nullable types with ? suffix - Quiz 2easy Operators and Expressions - Range operator (..) and in operator - Quiz 13medium Variables and Type System - Var for mutable references - Quiz 12easy Variables and Type System - Var for mutable references - Quiz 4medium