Write A Java Program to Check if a Given Integer is Odd or Even. - Pratik Ghelani

Pratik Ghelani

Breaking

Monday, January 28, 2019

Write A Java Program to Check if a Given Integer is Odd or Even.

Program:-

import java.util.Scanner;
public class problem1
{
public static void main(String[] args)
{
     int a;
        Scanner s = new Scanner(System.in);
        System.out.print("Enter the any number :");
        a = s.nextInt();
        if(a % 2 == 0)
        {
            System.out.println(""+a+" is Even ");
        }
        else
        {
            System.out.println(""+a+" is Odd ");
}
    }

}

Output:-






No comments:

Post a Comment