ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 2 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 23 Apr 2017 My Price 9.00

Write a function called fillArray

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

 

  1. Fill the array
  2. Print the array
  3. 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

 

image.jpg

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:

Answers

(11)
Status NEW Posted 23 Apr 2017 02:04 PM My Price 9.00

-----------

Not Rated(0)