Java Example to check if the entered number is Odd or Even. This example is for the beginners who just started learning programming.
import java.util.Scanner;
public class OddOrEven {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter the number: ");
int num = reader.nextInt();
if(num % 2 == 0)
System.out.println(num + " is even.");
else
System.out.println(num + " is odd.");
}
}
Watch video here
https://youtu.be/sX0XAROhuiQ
No comments:
Post a Comment