Q:

Write a Java Program to Check input number is Even or Odd

belongs to collection: Java Basic Solved Programs

0

Even numbers are those which are divisible by 2, and which numbers are not divisible 2 is called odd numbers.

In this program we receive input value from keyboard and find modulo 2 (n%2) of number if reminder of number is zero then that number is even other wise odd.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

SOURCE CODE ::

import java.util.Scanner;

public class Even_odd {

    public static void main(String[] args) {
        
        int n,i;
        
        System.out.println("Please Enter any No. u Want to Check :");
        
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        if(n%2==0)
        {
            System.out.println("Entered number is Even Number");
        }
        else
        {
            System.out.println("Entered number is Odd Number");
        }
        
    }
    
}

OUTPUT :: 

Please Enter any No. u Want to Check :
87
Entered number is Odd Number

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java Basic Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Java Program to find Factorial using While... >>
<< Write a Java Program to Check entered input is Pri...