Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++ Write a function called fillArray that will fill an array of any constant

ID: 3600692 • Letter: I

Question

In C++ Write a function called fillArray that will fill an array of any constantly declared array size variable with random numbers in the range of 1 - 100.

Write a function called printArray that will print an array of any size.

Write a third function called countEvens which will count and return the number of even numbers in the array.

In main create an array that holds 25 ints. Use your functions to fill, print, and count the number of even numbers. You should

Fill the array

Print the array

Print the number of even numbers in the array

What not to do:

Using any of the following will drop your grade for this assignment by an automatic 10 points

global variables

cout in any function other than main and printArray

goto statements

In C++

Your output should look like the following: In C++

Explanation / Answer

#include <iostream>

#include <ctime>

using namespace std;

void printArray(int arr[], int size);

int main()

{

            srand(time(0));

            const int size = 25;

            int fillArray[size];

            cout << endl;

            for (int i = 0; i < size; i++)

            {

                        fillArray[i] = rand() % 99 + 1;

            }

            printArray(fillArray, size);

            return 0;

}

void printArray(int arr[], int size)

{

            cout << "Printing the array" << endl;

            for (int i = 0; i < size; i++)

            {

                        cout << arr[i] << endl;

            }

            cout << "There are even numbers in the array" << endl;

}