Here is my assignment:
Assignment #15
CSC190Web
Spring 2002
__________________________________________________ ______________________
The purpose of this assignment is work with an array as well as writing several free functions.
It is assumed that the array will store N random numbers. The value of N will be entered from the keyboard using a free function and must be limited to having a value in the range 1 through 50. N also represent how many random numbers will be stored in our array.
__________________________________________________ ______________________
You are required to write the free functions for the following program as well as execute these free functions to be assured that they are correct.
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
const int MaxSize = 50;
// 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;
}



LinkBack URL
About LinkBacks


