C++ Code Example: even numbers in an array

This code example outputs all even numbers from an array. the modulo operator is used to check if the remainder of a given number divided by 2 equals 0.

#include <iostream>
using namespace std;

int main() {
    int numbers[] = {33, 431, 41, 76, 83, 99, 46, 9, 22};
    int arrayLength = end(numbers) - begin(numbers);

    for (int i = 0; i < arrayLength; i++) {
        if (numbers[i] % 2 == 0) {
            cout << numbers[i] << " ";
        }
    }

    return 0;
}
Output
76 46 22