Did i return this array properly
I have to create an array of random numbers, write a function that takes the array as an argument and return only even numbers, while using the function in the program. I used what I think is the passing array method, but I'm not sure if I've done it as I was instructed. Any advice is greatly appreciated. #include <iostream> #include <cstdlib> #include <ctime> using namespace std; void evenOnly (int [], int); int main() { srand(time(NULL)); int numbers[5]; int length = 5; evenOnly(numbers, length); return 0; } //srand(time(NULL)); void evenOnly(int numbers[], int length) { for (int i = 0; i < length; i++) { numbers[i] = (rand() % 170) + 1; if(numbers[i] % 2 == 0) { cout << numbers[i] << endl; } } }