Number is even or odd in java
8 . Number is even or odd in java
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
int a;
Scanner sc = new Scanner(System.in);
System.out.println("Find number is even or odd");
System.out.print("Enter a number : ");
a= sc.nextInt();
if (a % 2 == 0)
{
System.out.println("Even");
}
else
System.out.println("Odd");
}
}
output:-
Find number is even or odd Enter a number : 23 Odd Process finished with exit code 0
Comments
Post a Comment