How to find the Minimum of Three Numbers in Kotlin


How to find the Minimum of Three Numbers in Kotlin ?

Answer

To find the minimum of three numbers in Kotlin, you can use the `minOf` function.



✐ Examples

1 Find Minimum of Three Numbers

In this example,

  1. We declare three variables a, b, and c with the numbers to compare.
  2. We use the `minOf` function to compare the numbers and get the minimum.

Kotlin Program

fun main() {
    val a = 5
    val b = 8
    val c = 3
    val min = minOf(a, b, c)
    println("Minimum of three numbers is: $min")
}

Output

Minimum of three numbers is: 3

Summary

In this tutorial, we learned How to find the Minimum of Three Numbers in Kotlin language with well detailed examples.




More Kotlin Comparison Operations Tutorials

  1. How to find the Maximum of Two Numbers in Kotlin ?
  2. How to find the Minimum of Two Numbers in Kotlin ?
  3. How to find the Maximum of Three Numbers in Kotlin ?
  4. How to find the Minimum of Three Numbers in Kotlin ?