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

By | 20.01.2017

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


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.

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

 

4.5 2 votes
Article Rating
Category: Basic Programs Java Programming Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments