Kotlin Program to Check Even or Odd Number

In this post, we will learn how to write a Kotlin Program to check whether a number is Even or Odd.

Kotlin Program to Check Even or Odd Number

package com.kotlin.programs

fun main(args: Array < String > ) {

    print("Enter a number: ")
    val number = Integer.valueOf(readLine())

    if (number % 2 == 0)
        println("$number is even")
    else
        println("$number is odd")
}
Output:
Enter a number: 10
10 is even



Comments