COME 2 CODE
Learn by Yourself

Program to find whether the given number is Even or Odd

Hello friends, in this tutorial we are going to write a program to find whether the given number is even or odd. So, open your IDE and make a new Project. Now, write the following code in Main.java file.

Main.java :

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    int num;

    System.out.println("Enter the number : ");
    Scanner scanner = new Scanner(System.in);
    num = scanner.nextInt();

    if ((num % 2) == 0) {
      System.out.println("Number is even.");
    } else if ((num % 2) ==1) {
      System.out.println("Number is odd.");
    }
  }
}

Your output will be like this.

Output :

C:/Users/Username/Desktop>Enter the number :
197
Number is odd.
QUICK LINKS :