To find out Even and odd number in Java Programming.
To find out Even and odd number in Java Programming.
Theory : First
we have to take a veriable name num .Now we take a input from user .Then we
have to appy this theory(
if(num%2==0)
System.out.println("It is Even number ");
else
System.out.println(" It is Odd ");
Source code :
package
basicjava;
import java.util.Scanner;
public class EvenOdd {
public
static void main(String[] args) {
int num;
Scanner
input = new Scanner(System.in);
System.out.print("Enter the value of num: ");
num=input.nextInt();
if(num%2==0)
System.out.println("It is Even number ");
else
System.out.println(" It is Odd ");
}
}
Output :
Enter the value of num: 56
It is Even number
No comments