Kotlin Program to Find the Largest of Three Numbers

In this post, we will learn how to write a Kotlin Program to find the largest among three numbers.

Kotlin Program to Find the Largest of Three Numbers

package com.kotlin.programs

fun main(args: Array < String > ) {

    val number1 = 10
    val number2 = 20
    val number3 = 5

    if (number1 >= number2 && number1 >= number3) {
        println("$number1 is the largest number.")
    } else if (number2 >= number1 && number2 >= number3) {
        println("$number2 is the largest number.")
    } else {
        println("$number3 is the largest number.")
    }
}
Output:
20 is the largest number.



Comments