# Check even or odd number.

How to check given number is even or odd? May 23, 2012 at 5:51 PM

Simple if it is devided by 2 it is even and if not if is Odd May 23, 2012 at 5:53 PM

```import java.io.BufferedReader;
import java.io.IOException;

public class EvenNumber{

public static void main(String args[]) throws IOException {

Sys tem.out.println("Enter the number");
int num= 0;
String data = br.readLine();

num = Integer.parseInt(data);
if((num %2)==0){
System.out.println("Number is Even");

} else{

System.out.println("Number is Odd");

}
}
}
```

Description: num is variable which hold the inputted number. BufferReader is used for inputting number. Even numbers are those numbers, which are divisible by 2, and odd numbers are not divisible by 2. if((num %2)==0) is checking the condition of num divisibility. If divisible then it will print even number else odd number. May 25, 2012 at 12:37 AM

```/*
Even Odd Number Example
This Java Even Odd Number Example shows how to check if the given
number is even or odd.
*/

public class FindEvenOrOddNumber {

public static void main(String[] args) {

//create an array of 10 numbers
int[] numbers = new int[]{1,2,3,4,5,6,7,8,9,10};

for(int i=0; i < numbers.length; i++){

/*
* use modulus operator to check if the number is even or odd.
* If we divide any number by 2 and reminder is 0 then the number is
* even, otherwise it is odd.
*/

if(numbers[i]%2 == 0)
System.out.println(numbers[i] + " is even number.");
else
System.out.println(numbers[i] + " is odd number.");

}

}
}

/*
Output of the program would be<br>
1 is odd number.<br>
2 is even number.<br>
3 is odd number.<br>
4 is even number.<br>
5 is odd number.<br>
6 is even number.<br>
7 is odd number.<br>
8 is even number.<br>
9 is odd number.<br>
10 is even number.<br>
*/
```

Related Tutorials/Questions & Answers:
Check even or odd number.
Check even or odd number.  How to check given number is even or odd?   Simple if it is devided by 2 it is even and if not if is Odd  ...){ System.out.println("Number is Even"); } else
Even and odd functions in java
); int number; System.out.println("Input any number to check even... have two separate functions for checking either number is even or odd. We...Even and odd functions in java  Even and odd functions in java
Odd Even Transposition Sort In Java
pair off either the odd or even neighboring pairs. Each number (In Processing... Odd Even Transposition Sort In Java   ... In this example we are going to sort integer values of an array using odd even
Check Even-Odd:-Example
reads a integer value and check weather number is Odd or Even. In this example you will learn how to determine the Even or Odd for the given number entered... Check Even-Odd:-Example
A program to find the sum of odd number
A program to find the sum of odd number In this section you will learn how to find the sum of odd number in the series up to the given number in java...; } System.out.println("Sum of odd number = "+sum
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
To check a palindrome number?
To check a palindrome number?  program to check a number is palindrome or not using recursion?(wihout converting to string
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement  hi class Even{ public static void main(String[] arg){ int num=Integer.parseInt
Check whether the number is palindrome or not
Check whether the number is palindrome or not A palindrome is a word, phrase... direction. Here we are going to check whether the number entered by the user... is by  reversing the digits of the original number and check to see
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
Check whether the sum of alternate digit of a number is palindrome or not.
Check whether the sum of alternate digit of a number is palindrome... are going to check whether the sum of the alternate digit of a number entered... of this number be 2+4+6 i.e 12) and then check whether this sum is palindrome
ModuleNotFoundError: No module named 'odd'
ModuleNotFoundError: No module named 'odd'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odd' How to remove the ModuleNotFoundError: No module named 'odd' error
odd numbers with loop
odd numbers with loop  get the odd numbers till 100 with for,while loop   Java find odd numbers: class OddNumbers { public static void main(String[] args) { for(int i=1;i<=100;i
ModuleNotFoundError: No module named 'odd-bunch'
ModuleNotFoundError: No module named 'odd-bunch'  Hi, My Python... 'odd-bunch' How to remove the ModuleNotFoundError: No module named 'odd... have to install padas library. You can install odd-bunch python with following
How to list even numbers between 1 and 100?
How to list even numbers between 1 and 100?  Hi, I Java to check if a number is even? How to list even numbers between 1 and 100? Thanks   Hi, If number is divisible by 2 then its even number. Suppose you have
check
updated"); will the above code check if the user has entered value for empcode
Java number calculation using while loop
); } } } Output: Enter First Number: 4 Enter Second Number: 20 Odd Numbers...Java number calculation using while loop In this tutorial, you will learn how to use while loop to solve certain number calculations. Here is an example
Prime number program in java
or not. Example : Here is the code for generating prime number and to check the prime number... number"); System.out.println("Press 2 for check prime number "...Prime number program in java In this example you will learn how to write
prime number
prime number  get one number and check the number prime or not using if statement   Java Check Prime Number
prime number
prime number  check prime number using if statement   Java Check Prime Number
prime number
prime number  check prime number using if statement   Java Check Prime Number
Number in array
Number in array  How to write a program to check the number that we are entered from keyboard is in the given array
prime number
prime number  To check a number entered by user is prime or not?   Java check prime number import java.util.*; class CheckPrimeNumber { static boolean isPrime(int number){ boolean isPrime=false
prime number
prime number  To check a number entered by user is prime
prime number
prime number  to check wethere given number is prime or not?  ... { static boolean isPrime(int number){ boolean isPrime=false; int i=(int) Math.ceil(Math.sqrt(number)); while (i>1
print the even numbers between the range 100-200
print the even numbers between the range 100-200  Q ?write an application that print out the even numbers between the range 100-200 ? 1- which aer not divisible by 7 and 5 ? 2- Number of the numbers which are not divisible
ModuleNotFoundError: No module named 'even_detector'
ModuleNotFoundError: No module named 'even_detector'  Hi, My... 'even_detector' How to remove the ModuleNotFoundError: No module named 'even_detector' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'even_detector'
ModuleNotFoundError: No module named 'even_detector'  Hi, My... 'even_detector' How to remove the ModuleNotFoundError: No module named 'even_detector' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'even-tester'
ModuleNotFoundError: No module named 'even-tester'  Hi, My Python... 'even-tester' How to remove the ModuleNotFoundError: No module named 'even-tester' error? Thanks   Hi, In your python environment
Listing all even numbers between two numbers
the numbers. Check the tutorial Write a program to list all even numbers between two...Listing all even numbers between two numbers  Hi, How to write code to list all the even numbers between two given numbers? Thanks   Hi
write an application that print out the even numbers between the range 100-200
write an application that print out the even numbers between the range 100-200   write an application that print out the even numbers between the range 100-200 ?   The given code accepts the number from 100 to 200
Mysql Mod
you use MOD(a, 3) you get 1 for even numbers and 0 for odd numbers. If you use MOD(a, 2) you get the last digit of the number a. Understand with Example
the number of parameters
the number of parameters  How do I find out the number of parameters passed into function
prime number
prime number  could u pls help me out in finding whether a number is a prime number or not?   import java.util.*; class CheckPrimeNumber { static boolean isPrime(int number){ boolean isPrime=false
to read number from user
to read number from user  1)print the positive equivalent of the number 2) check if the no is integer or not 3) find the square root of the number 4) find the cube of the number
Armstrong number
Armstrong number  I want java program for Armstrong number
prime number
prime number  write a java program for prime number
prime number
prime number  HI!I want a java program that accepts a number from user and displays whether it is a prime number or not using BufferedReader
ModuleNotFoundError: No module named 'does-this-even-work-anymore'
ModuleNotFoundError: No module named 'does-this-even-work-anymore'  ...: No module named 'does-this-even-work-anymore' How to remove the ModuleNotFoundError: No module named 'does-this-even-work-anymore' error? Thanks
ModuleNotFoundError: No module named 'even-more-itertools'
ModuleNotFoundError: No module named 'even-more-itertools'  Hi, My... named 'even-more-itertools' How to remove the ModuleNotFoundError: No module named 'even-more-itertools' error? Thanks   Hi
Count number of "*"
Count number of "*"  I have this code to count the number of * from a string entered. but I need to find it from an text file. Any idea? import...++; } } System.out.println("The number of vowels in the given sentence
Number Pyramid
Number Pyramid  Hi Everyone, Can someone help me write the code for the following number pyramid: print... 0 0 0 0 4 ... "); There is 5 spaces in between each number
How to format number in Java?
How to format number in Java?  Hi, What is the best way to format a number in Java? How to format number in Java? Thanks   Hi, To format number in Java you can use the class java.text.NumberFormat. Here is simple
log4j is not logging even under src path
log4j is not logging even under src path  We are working with struts application and using log4j.properties file , it is placed under WEB-INF/classes and we have referenced log4j-1.2.8.jar in classpath file even after