In: Computer Science
in C++,
#include<iostream>
using namespace std;
const int NUM = 10;
void prepareArr(int a[]);
int countEven (int b[]);
int main() {
int arr[NUM];
// write a statement to call prepareArr to set values for the array
// write a statement to call countEven and print the data returned
for(int i = 0; i<NUM; i++)
cout << arr[i] <<" ";
cout <<endl;
return 0;
}
void prepareArr(int a[])
{
//randomly generate NUM integers in the range [0,99] and save them in the array parameter.
}
int countEven (int b[])
{
//count the number of even integers in the array parameter and return the number, note that the size of the array is specified with NUM.
}
Previous
Have a look at the below code. We can use rand() function to generate random numbers. I have put comments wherever required for better understanding.
Happy
Learning!