here is what I've done:
Code:
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
const int MaxSize = 50;
void main()
{
// The following are prototypes declaring functions invoked doing the
// execution of function main.
void HowManyRandomNumbers(int& N);
void GenerateRandomNumbers( int A[], int N );
int CountEvenNumbers( int A[], int N );
void DisplayArray ( int A[], N);
void main()
{
srand(time(0));
// Create the array Arr:
int Arr[MaxSize];
int N, Count;
// Have the user enter a count on the number of random numbers he/she
// wishes to generate.
HowManyRandomNumbers( N );
// Store N random numbers in array Arr.
GenerateRandomNumbers( Arr, N );
// Count the number of even integers stored in array Arr.
Count = CountEvenNumbers( Arr, N );
// Display the N values stored in array Arr and the count on the number
// of even integers stored in array Arr.
DisplayArray(Arr, N);
cout << "\n Count on even integers: " << Count << endl;
}
// ------------------------------------------------------------------ //
// Function Definitions //
// ------------------------------------------------------------------ //
// Purpose: This function asks for and inputs the amount of random numbers
// that the user would like used in the program.
void HowManyRandomNumbers(int& N)
{
cout << "How many random numbers would you like generated?";
cin >> N >> endl;
}
// Purpose: This function generates random numbers that are assigned as
// elements of array Arr.
void GenerateRandomNumbers(int Arr[], int N )
{
for( int N = 0; N < MaxSize; ++N)
{
Arr[I] = rand() % 1000;
}
}
// Purpose: This function counts and returnsthe even numbers inn array Arr.
int CountEvenNumbers( int Arr[], int N )
{
long Even = 0;
for( int N = 0; N < MaxSize; ++N)
{
if( Arr[N] % 2 == 0 )
{
Even ++;
}
}
return Even;
}
// Purpose: This function displays the elements of array Arr.
void DisplayArray (int Arr[], int N)
{
cout << "Array elements: " << endl;
for(int N = 0; N < MaxSize; ++N)
{
cout << "Arr[" << N << "] = " << Arr[I] << endl;
}