India's Largest Free Online Education Platform

Java Program to Check Even or Odd number

Java program to check Even or Odd number

Code:

import java.util.Scanner;
public class Odd_Even
{
    public static void main(String args[])
    {
        System.out.println("Enter a integer number to check it is odd or even");
        Scanner Sc= new Scanner(System.in);
        int x= Sc.nextInt();
        if(x%2==0)
            System.out.println("Given no "+x+" is even number");
        else
            System.out.println("Given no "+x+" is odd number");

    }
}

Output:01

Output-02

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!