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
Free Spring Boot Tutorial - 5 Hours Full Course
Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course