Write a program to check number is even or odd in java.
import java.util.Scanner;
class Even
{
public static void main(String args[])
{
int a;
Scanner s=new Scanner(System.in);
System.out.println("Enter no");
a=s.nextInt();
if(a%2==0)
{
System.out.println("no is even");
}
else {
System.out.println("No is odd");
}
}
}
import java.util.Scanner;
class Even
{
public static void main(String args[])
{
int a;
Scanner s=new Scanner(System.in);
System.out.println("Enter no");
a=s.nextInt();
if(a%2==0)
{
System.out.println("no is even");
}
else {
System.out.println("No is odd");
}
}
}
Output:
Comments
Post a Comment
If you have any query, please let us know