Differentiating between even and odd numbers in an array

Report a typo

Consider an array of integers. We need to write a program that can iterate through the array and differentiate between even and odd numbers, printing the result to the console. You are given a partially completed code. Your task is to fill the blanks in the code, correctly completing the syntax for the loop condition and limit.

Fill in the gaps with the relevant elements
public class Main {
    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5};
         (int i = 0; i < ; i++) {
            if (array[i] % 2 == 0) {
                System.out.println("Even number: " + array[i]);
            }
            else {
                System.out.println("Odd number: " + array[i]);
            }
        }
    }
}
array.lengthfor
___

Create a free account to access the full topic