EvenOdd.java
Aim:
To find whether the given number is Even or Odd.
Source code:
import java.lang.*;
import java.util.*;
class EvenOdd
{
public static void main(String args[])
{
int n;
System.out.println("Enter value for n");
Scanner input=new Scanner(System.in);
n=input.nextInt();
if(n%2==0)
System.out.println("Even Number");
else
System.out.println("Odd Number");
}
}
Output-1:
Enter value for n
4
Even Number
Output-2:
Enter value for n
7
Odd Number
No comments:
Post a Comment