How to list even numbers between 1 and 100?

Ads
 

How to list even numbers between 1 and 100?

Hi,

I Java to check if a number is even?

How to list even numbers between 1 and 100?

Thanks

View Answers

April 16, 2017 at 5:08 PM

Hi,

If number is divisible by 2 then its even number.

Suppose you have a variable i then you can use following code for finding if the number is even:

if(i%2==0 ){
//Number is even
}

You can use the for loop and print all the numbers between 1 and 100

for (int i=1;i <=num ; i++){
  if(i%2==0 ){
  System.out.print(i+",");
  }

Check complete example at Write a program to list all even numbers between two numbers.

Thanks

Ads









Related Tutorials/Questions & Answers:
How to list even numbers between 1 and 100?
Listing all even numbers between two numbers
Advertisements
Java Find Automorphic numbers
Write a program to list all even numbers between two numbers
print the even numbers between the range 100-200
Prime numbers in Java between 1 and 100
write an application that print out the even numbers between the range 100-200
Java write even numbers to file
How to generate a list of random numbers?
EVEN NUMBERS - Java Interview Questions
Check whether highest number is even or odd
Calculate sum of even and odd numbers in Java
print the sum of even number from 1 to 100
Program to display palindrome numbers between some range
Generate random number between two numbers in Scala
mysql difference between two numbers
Generate random numbers from 1 to 100
how to add to numbers in java
How to get of lastmodified file list between two times in java?
How to use List in velocity
Generate random numbers in Java
How to put text file numbers to array and check the position of numbers?
PRIME AND EVEN AND ODD - Java Interview Questions
How to Addding 1 Year with PHP
How to use between in mysql.
how I make the numbers in descending order ?
display 1000 of records - Struts
Find Numbers which are palindrome and prime
How to add two numbers in Java?
odd and even
numbers

Ads