Write a program that declares an array named myArray with 8 components of the type
int. Initialize the array to 8 values that the user will input. Finally, pass the array as a
parameter to a new function called filterEvens. This new function will display all of the
even numbers in the array.
#include <iostream>
//Function Prototypes.
void filterEvens(int[], int);
int main()
{
constint s{ 8 };
//declares an array named
//myArray with 8 components of the type int.
int myArray[s]{0};
// Initialize the array to 8 values that
// the user will input.
for (int x = 0; x < s; x++)
{
std::cout << "Number " << x + 1 << " :";
std::cin >> myArray[x];
}
//Print Arrays.
filterEvens(myArray, s);
return 0;
}
// TO DO:
// This new function will display all of the
// even numbers in the array.
void filterEvens(int myArray[], int s)
{
for (int x = 0; x < s; x++)
std::cout << myArray[x] << std::endl;
}