1. Engineering
  2. Computer Science
  3. create a program that creates an array of 500 random...

Question: create a program that creates an array of 500 random...

Question details
Create a program that creates an array of 500 random numbers between -10 and 10.

Write several functions:

Function 1 - prints the array with a certain number of elements per line. Prototype: void printArray(int array[], int numElements, int numPerLine, ostream &os)
Function 2 prints only the array elements that are evenly divisible by an input number. Prototype: void printDivBy(int array[], int numElements, int numPerLine, int divBy, ostream &os)
Function 3 takes the input array and returns the maximum, the next-to-maximum, the minimum, and the next-to-minimum values
Function 4 returns the sum of the values in the array
Also calculate the average of the array. Your program should call each function; use the number 8 for numPerLine for the printArray function, and use 5 for numPerLine and the number 3 for the divBy value when calling the printDivBy function. Print the max, next-to-max, min, and next-to-min, the sum, and the average of the numbers from main, not from the function. Print the

Your program MUST use arrays. Your program should NOT call a sort function.

Using c++

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution