java program to print odd and even numbers between 1 and 100

Solutions on MaxInterview for java program to print odd and even numbers between 1 and 100 by the best coders in the world

showing results for - "java program to print odd and even numbers between 1 and 100"
Mercedes
07 Sep 2020
1// Java program to print odd and even numbers between 1 and 100
2public class EvenOddBetween1And100
3{
4   public static void main(String[] args)
5   {
6      System.out.println("Even numbers between 1 and 100: ");
7      for(int a = 1; a <= 100; a++)
8      {
9         if(a % 2 == 0)
10         {
11            System.out.print(a + " ");
12         }
13      }
14      System.out.println("\nOdd numbers between 1 and 100: ");
15      for(int a = 1; a <= 100; a++)
16      {
17         if(a % 2 != 0)
18         {
19            System.out.print(a + " ");
20         }
21      }
22   }
23}