Saturday, 29 August 2020

Odd or Even number identify in simple way

Write a program to find Number is a Odd number or Even number.
import java.util.Scanner;
public class EvenOdd 
{
	public static void main(String[] args) 
	{
		Scanner scan = new java.util.Scanner(System.in);
		System.out.println("Enter the number: ");
		int number=scan.nextInt();
		//condition used to identify number is odd or even
		if(number%2==0)
		{
			System.out.println(number + " is Even number");
		}
		else
		{
			System.out.println(number + " is odd number");
		}
	}
}

Output:
Enter the number: 
64
64 is Even number  


  

No comments:

Post a Comment

If you have any doubts, please let me know

Pattern 31 & 32