Monday, 5 January 2015

Java Program to check whether a number is Even Or Odd


This is a basic java program which checks whether the given number is even or odd.

PROGRAM :


package codingcorner.in;

import java.util.Scanner;

public class EvenOrOdd {

 public static void main(String[] args) {

  Scanner scan = new Scanner(System.in);

  System.out.println("Enter any number");
  int number = scan.nextInt();

  scan.close();

  if (number % 2 == 0)
   System.out.println(number + " is EVEN number");
  else
   System.out.println(number + " is ODD number");

 }
}

OUTPUT :







No comments:

Post a Comment