Java Program to get whether a number is odd or even using if else condition…

This java code is to find out whether a number is even or odd using if_else condition.
class EvenOdd
{
      public static void main(String args [])
      {
                  int no;
                  no=Integer.parseInt(args [0]);
                 
                  if(no%2==0)
                  {
                              System.out.println(“no is even”);
                  }
                  else
                  {
                              System.out.println(“no is odd”);
                  }
      }
}
Output:

D:java >java EvenOdd 5

no is odd

Add Comment