Find odd digits in an integer value in Java

While an odd number is a number which has a remainder of 1 upon division by 2.

If the units digit is 1,3,5,7, or 9, then the number is called an odd number, and if the units digit is 0,2,4,6, or, or 8, then the number is called an even number.

ALGORITHM

Step 1- Start the program.
Step 2- Read/input the number.
Step 3- if n%2==0 then the number is even.
Step 4- else number is odd.
Step 5- display the output.
Step 6- Stop the program.

CODE

import java.io.*;
import java.util.Scanner;
class PrepBytes
{
public static void main(String[] args)
{
int num = 10;
if (num % 2 == 0) {
System.out.println(“Entered Number is Even”);
}
else
{
System.out.println(“Entered Number is Odd”);
}
}
}

OUTPUT

Entered Number is Even

Leave a Comment

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

Scroll to Top