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

Ads









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
How to generate a list of random numbers?
How to generate a list of random numbers?
How to generate a list of random numbers?
Program to display palindrome numbers between some range
print the sum of even number from 1 to 100
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?
How to use List in velocity
How to use between in mysql.
list of all months between two dates in java
list of all months between two dates in java
how I make the numbers in descending order ?
How to add two numbers in Java?
How to Addding 1 Year with PHP
Create a multi-thread program that calcualtes values for a list of numbers
Mysql Mod
Check even or odd number.
how to get string between two characters

Ads