Kotlin Program to find the greatest number of three numbers


In this program, You will learn how to find the greatest number among the three numbers in Kotlin.


10 20 30 => 30

20 10 19 => 20

Example: How to find the greatest number of three numbers in Kotlin.

import java.util.Scanner

fun main(args: Array<String>) {

    var a: Int
    var b: Int
    var c: Int

    var sc = Scanner(System.`in`)

    print("Enter three numbers:")
    a = sc.nextInt()
    b = sc.nextInt()
    c = sc.nextInt()

    if (a > b && a > c) {
        println("Greatest is :$a")
    } else if (b > c) {
        println("Greatest is :$b")
    } else {
        println("Greatest is :$c")
    }
}

Output:

Enter three numbers:10 20 15
Greatest is :20