Java program to check a number is odd or even. This is a normal program to calculate the even odd number.
Do practice.
go to the java link: click here

Source Code:

  1. public class EvenOddDemo {
  2. public static void main(String[] args) {
  3. try (// TODO Auto-generated method stub
  4. Scanner input = new Scanner(System.in)) {
  5. int num;
  6.  
  7. System.out.print("Enter the number: ");
  8. num = input.nextInt();
  9. if(num %2==0) {
  10. System.out.println("The number is Even.");
  11. }
  12. else {
  13. System.out.println("The number is odd.");
  14. }
  15. }
  16. }
  17. }

Output:


Enter the number: 84553
The number is odd.

Enter the number: 1548856
The number is Even.

0 comments:

Post a Comment