# Kotlin Program To Check Number is Odd or Even

###### Greetings!
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners. Also, if you are interested in content writing, you can mail us at tutorialwing@gmail.com.

In this post, we will go through Kotlin program to check if number is odd or even.

###### How do you check whether number is odd or even?

Answer – When it is divided by 2 and remainder is 0. Then, it is even. Otherwise it’s odd.

## Program to Check Odd or Even in Kotlin

Sourcecode –

```import java.util.*

fun main(args: Array<String>) {

println("Enter integer number:")

// Logic to check even
val isEven = ((a % 2) == 0)

val res = "Entered value is " + (if (isEven) "Even" else "Odd")

println(res)
}
```

When you run the program, output will be –

``` Enter integer number:
43
Entered value is Odd
```

Logic to check for even number –
((a % 2) == 0) .

Here, % returns remainder when you divide a number by other number.

So, When you enter 43, it is divided by 2 and remainder is checked if it is 0 or not.
Since remainder for 43 will be 1, it’s an odd number.

Thus, we went through program to check if number is odd or even in Kotlin