Subscribe Our Channel

header ads

Search This Blog

Friday, July 28, 2023

Java program to check whether input number is EVEN or ODD | JAVA LANGUAGE | JAVA PROGRAMMING

To check number is EVEN or ODD: we will divide number by 2 and check remainder is ZERO or not, if remainder is ZERO, number will be EVEN others number will be ODD.


import java.util.*;


/* Java Program to check whether entered number is EVEN or ODD */


public class j6 {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        int num;


        //inpu

        System.out.print("Enter an integer number: ");

        num = sc.nextInt();


        //check EVEN or ODD

        if (num % 2 == 0) {

            System.out.println(num + " is an EVEN number.");

        } else {

            System.out.println(num + " is an ODD number.");

        }

    }

}

No comments:

Post a Comment

Featured Post

Happy Republic Day Wish Using HTML and CSS | 26 January wish using HTML/CSS

 Happy Republic Day Wish Using HTML and CSS, 26 January wish using HTML/CSS <!-- WELCOME ALL OF YOU ON COMPUTER SOFT SKILLS CHANNEL -----...

Popular Posts