How to list even numbers between 1 and 100?

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









Related Tutorials/Questions & Answers:
How to list even numbers between 1 and 100?
Listing all even numbers between two numbers
Advertisements
Write a program to list all even numbers between two numbers
Java Find Automorphic 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?
How to generate a list of random numbers?
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
Generate random number between two numbers in Scala
mysql difference between two numbers
Generate random numbers from 1 to 100
How to get of lastmodified file list between two times in java?
how to add to numbers in java
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 use List in velocity
list of all months between two dates in java
list of all months between two dates in java
display 1000 of records - Struts
How to use between in mysql.
JSTL - check odd/even number - JSP-Servlet
Create a multi-thread program that calcualtes values for a list of numbers
numbers
Find Numbers which are palindrome and prime
how I make the numbers in descending order ?
How to add two numbers in Java?
odd and even
How to Addding 1 Year with PHP
Check even or odd number.
Mysql Mod
Version of com.klinkerapps>enlarged_numbers dependency
How does this example work even if no oracle to be used and only access is available?
Printing numbers up to N into a file
random numbers
How to print a equilateral triangle patren with numbers
how to get string between two characters
how to write a program in java to print numbers in equalateral triangle
How to Create Multiplication Table from 1 to 10?
Convert Roman Numbers to Decimal Numbers
How to manage cookie in between two JSP Pages

Ads