###### 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>) { val read = Scanner(System.`in`) println("Enter integer number:") val a = read.nextInt() // 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

## Support Us

If you like

**Tutorialwing**and would like to contribute, you can email an article on any educational topic at tutorialwing@gmail.com. We would love to publish your article. See your article on Tutorialwing and**help others with your knowledge**. Follow Facebook, LinkedIn, Google+, Twitter, Youtube for latest updates.