Q:

Write a Kotlin program to create an array of size 10 containing

0

Write a Kotlin program to create an array of size 10 containing

0
2
4
6
8
10
12
14
16
18

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution:

fun main(args : Array<String>)  {  
	val x = Array(10) { i -> i * 2 }
	for(s in x){
		println(s);
	}
}

Output:

0
2
4
6
8
10
12
14
16
18

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now