CS Electrical And Electronics
@cselectricalandelectronics

For loop in Kotlin to print value from 10 to 1?

All QuestionsCategory: KotlinFor loop in Kotlin to print value from 10 to 1?
chetan shidling asked 3 years ago

I need short information.

1 Answers
chetan shidling answered 3 years ago

Here is the code to print values from 10 to 1 in Kotlin.
 
fun main(args : Array<String>){
var nums = 10 downTo 1

for(a in nums)
{
println(a)
}
}
 
Output:
 
10
9
8
7
6
5
4
3
2
1