How to Check if Given Integer is Even or Odd using If... Else Statement in Java

preview_player
Показать описание
Hi guys! In this video i will show you how to solve a simple problem:

Write a Java program that takes integer as input and check whether the number is even or odd.

So to solve this we must understand what is even or odd number:
In general Even numbers are those which are divisible by 2, and which numbers are not divisible by 2 is called Odd number.
But in term of programming for finding even number we check remainder of number is zero or not, If remainder is equal to zero that means number is divisible by 2. To find remainder of any number we use modulo (%) operator which return remainder as result.
Number%2
If number%2==0 then EVEN NUMBER
If number%2==1 then ODD NUMBER

I will use If Else Statement to apply the condition above.

(Note: I used Eclipse IDE for Java Developers - 2019-12 and also I'm using Scanner class to accept user input)

If you like this video DON'T FORGET TO LIKE AND SUBSCRIBE TO MY YOUTUBE CHANNEL to see more programming videos!!!

#java
#javaprogramming
#javaprogrammingwitheclipse
#evenodd
#evenoddusingifelsestatement
#dmtenio

You may also try to watch this video:

How to Check if Given Integer is Positive, Negative or Zero in Java

How to Check if Given Integer is Even or Odd using Switch Statement in Java
Рекомендации по теме
Комментарии
Автор

sir ang largest og smallest number nasad.. :D

godfreyamba
visit shbcf.ru