Print Even-Odd Number

fun main() {
    println("Enter a Integer Number")//1
    val number = readLine()?.toInt()!!//2
        println("Entered Number is Even=$number")//4
        println("Entered Number is Odd=$number")//5

1 Instruct the user to Enter a Integer value
2 Take value from command line and  convert it into Int and assign to number variable
3 Check Entered Number is Even or Odd using if statement
4 If statement true then on command line Entered Number is Even=20
5 If statement false then on command line Entered Number is Odd=5

Enter a Number
 Entered Number is Even

Enter a Number
 Entered Number is Odd

Leave a Reply

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