Program to check given number is even or odd in java language.
Ved varshney 》
import java.util.*;
public class evenodd {
public static void main(String[] args) {
int num;
Scanner sc=new Scanner(System.in);
System.out.println("enter a number=");
num=sc.nextInt();
if(num%2==0)
{
System.out.println("number is even.");
}
else
{
System.out.println("number is odd.");
}
}
}
■》 Output->
enter a number= 9
number is odd.
Comments
Post a Comment