New course! Every coder should learn Generative AI!
Try a free lesson+ 4
Here we go!
https://code.sololearn.com/cVb3jtC4j0hB/?ref=app
+ 5
for this kind of task, the do ... while loop could be a good solution:
fun main(args: Array<String>) {
var count = 0
do{
var num = readLine()!!.toInt()
count++
} while (num != 0)
println(count - 1)
}
+ 1
fun main(args: Array<String>) {
var i= 0
while(true) {
var input = readLine()!!.toInt()
i++
if(input==0) break
}
println(i-1)
}
--
I hope this code helped!