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: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
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;
}
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly