Even and Odd Number in Java
Program :-
// Q1. Write a program in where find enter number is even ot odd
import java.util.*;
class EvenOdd{
public static void main(String arg[]){
// int num;
System.out.println("Enter a Random Number Find Even Or Odd:");
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
if(num %2==0){
System.out.println("This is Even Number");
}
else{
System.out.println("This is Odd Number");
}
}
}
Output:
PS D:\Learning File\BCA\BCA 3rd Sem\JAVA OOP\allpraque> java EvenOdd
Enter a Random Number Find Even Or Odd:
5
This is Odd Number
PS D:\Learning File\BCA\BCA 3rd Sem\JAVA OOP\allpraque> java EvenOdd
Enter a Random Number Find Even Or Odd:
4
This is Even Number
Comments