Vidyalelo
Computer Science · Q201

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications

Engineering and GATE · Computer Science · question 201

Q201

Which code snippet correctly shows a for loop using a range to display "1 2 3 4 5 6"?

A.
for(z in 1..7) println("$z ")
B.
for(z in 1..6) print("$z ")
Answer
C.
for(z in 1 to 6) print("$z ")
D.
for(z in 1..7) print("$z ")

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board