Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions OddEven.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
public class OddEven {
public static void main(String args[]) {
int n = 10;
int bitMask = 1;
if((n & bitMask) == 0) {
System.out.println("even");
} else {
System.out.println("odd");
}
import java.util.Scanner;

public class EvenOdd {

public static void main(String[] args) {

Scanner reader = new Scanner(System.in);

System.out.print("Enter a number: ");
int num = reader.nextInt();

if(num % 2 == 0)
System.out.println(num + " is even");
else
System.out.println(num + " is odd");
}
}