Q:

How to get average of the given array elements in Kotlin

belongs to collection: Kotlin programming Exercises

0

How to get average of the given array elements in Kotlin 

doubleArrayOf(2.5, 1.8, 3.4)

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 = doubleArrayOf(2.5, 1.8, 3.4)
	val y = x.average()
	println(y)
}

Output:

2.5666666666666664

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

total answers (1)

Write a program in Kotlin to get length of the giv... >>
<< Write a program in Kotlin to get length of the giv...