The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
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
Â
Â
What not to do:
Â
Â
I have everything down except for the third function. I am drawing blanks.
Â
#include <iostream>#include <ctime>#include <stdlib.h>using namespace std;void printArray(int arr[], int size);int countevens(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;}return ;}int countevens(int arr[], int size)int evencount = 0;{for (int i = 0; i < size; i++)if (arr[i] % 2 == 0)evencount++;{cout << "There are " << evencount << " even numbers in the array" <<endl;}return evencount;}
Attachments: