Saturday 3 May 2014

So here's the program of finding ODD AND EVEN numbers in JAVA !!


import java.util.Scanner;
 
class EvenOdd
{
  public static void main(String args[])
  {
    int c;
    System.out.println("Input an integer");
    Scanner in = new Scanner(System.in);
    c = in.nextInt();
 
    if ( (c/2)*2 == c )
      System.out.println("Even");
    else
      System.out.println("Odd");
  }
}

No comments:

Post a Comment