Find Greater Number

fun main() {
    println("Enter Two Integer Numbers")//1
    val first = readLine()!!.toInt()//2
    val second = readLine()!!.toInt()//3

    if(first>second)//4
    {
        println("First Entered Number is Greater=$first")//5
    }
    else
    {
        println("Second Entered Number is Greater=$second")//6
    }
}

  1. Instruct the user to enter two number
  2. Convert user first entered number into int and assign to variable name first
  3. Convert user second entered number into in and assign to a variable name second
  4. If the condition is used to check which number is greater from entered number
  5. Execute the if block when the first number is greater
  6. Execute the else block when the second number is greater

Output

Enter Two Integer Numbers
10
67
Second Entered Number is Greater=67

Enter Two Integer Numbers
78
10
First Entered Number is Greater=78

Leave a Reply

Your email address will not be published. Required fields are marked *