find even numbers to an array

Solutions on MaxInterview for find even numbers to an array by the best coders in the world

showing results for - "find even numbers to an array"
Nino
25 Jul 2018
1/**
2 * This program displays even values
3 * of array.
4 */
5public class EvenArray
6{
7   public static void main(String[] args)
8   {
9      int[] list = { 2, 5, 16, 18, 21 };
10
11      // Display all even elements of array
12      System.out.println("The even numbers of array:");
13
14      for (int i = 0; i < list.length; i++)
15      {
16         if (list[i] % 2 == 0)
17         {
18            System.out.print(list[i] + " ");
19         }
20      }
21
22      System.out.println();
23   }
24}
similar questions
queries leading to this page
find even numbers to an array