Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.
An even number is divisible by 2 and leaves a remainder of 0. In addition to 0, 2, 4, 6, and 8, all numbers ending with 0 and 2 are even. Alternatively, an odd number contains a remainder of 1 and is not divisible by 2. Odd numbers include 1, 3, 5, 7, and 9.
Following is the Java program that checks if a given number is odd or even.
Code Example:
import java.util.Scanner;
public class OddEven
{
public static void main(String[] args)
{
int num;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number you want to check:");
num = sc.nextInt();
if(num % 2 == 0)
{
System.out.println("The entered number "+num+" is Even ");
}
else
{
System.out.println("The entered number "+num+" is Odd ");
}
}
}
Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.
Start Free TestingEarn resume-worthy Selenium certifications that help you land a top job.
Learn MoreTest orchestration and execution cloud of 3000+ browsers and OS
24/7 support
Enterprise grade security
Fastest test execution cloud