WAP to check whether a number is odd or even using scanner.

3 years ago
OOP Java

Compile code:

import java.util.Scanner;

    class Odd_Even {

    public static void main(String[] args) 

    {

        int n;

        Scanner s = new Scanner(System.in);

        System.out.print("Enter the number :");

        n = s.nextInt();

        if(n%2 == 0)

        {

            System.out.println("The given number "+n+" is Even ");

        }

        else

        {

            System.out.println("The given number "+n+" is Odd ");

    }

    }

}

 

Output:

0
Dipti KC
Jan 8, 2023
More related questions

Questions Bank

View all Questions