To start, you're going to make an array that's full of random integers. This array should have a number of elements that is controlled by a global constant int, like this: const int SIZE = 20; You...

1 answer below »

To start, you're going to make an array that's full of random integers. This array should have a number of elements that is controlled by a global constant int, like this:  const int SIZE = 20;  You should do a few different things with your array. First, you need to fill it with the random numbers. The rand() function will give you a random integer from 0 to RAND_MAX (a big number). To access the rand() function, you may need to include the library . Also, the numbers that you put into the array should only be between 0 and 100. The function prototype to fill your array should look like this:  void fill(int arr[SIZE]);  You should not need to pass the SIZE constant to your function as an argument since it's globally declared. Next, you should print out the contents of the array. The function prototype to print your array should look like this:  void print(int arr[SIZE]);  and here is a sample output of an array printing  41 67 34 0 69 24 78 58 62 64 5 45 81 27 61 91 95 42 27 36  Next, you should print a chart of ranges of numbers. The ranges you should use are 0-9, 10-19, 20-29, ... 90-99. For each range, you will print a star for each number that is in the range. The function prototype will look like this:  void printRanges(int arr[SIZE]);  and here is the sample output corresponding to the array above  00: ** 10: 20: *** 30: ** 40: *** 50: * 60: ***** 70: * 80: * 90: **  Lastly, you're going to use a filter to smooth the above data. This is a fancy way of saying something quite simple. You want the numbers to be closer to the values of their neighbors. To accomplish this, you use a 'moving average,' where you average each number with it's neighbors to get a new value. In the example above, the new zeroeth element would be 54 since that's the average of 41 and 67. The next value would be 47 since (41+67+34)/3 = 47. Here is the prototype for the moving average:  void movingAverage(int arr[SIZE]);  and here is the sample output corresponding to the array above  54 47 33 34 31 57 53 66 61 43 38 43 51 56 59 82 76 54 35 31  In main, you should use these functions in the following way. Declare and fill an array then print its values and ranges. Next, apply the movingAverage function to the array ten times, then reprint the ranges. Did the graph change in the way you expected? Why or why not?
Answered Same DayJul 27, 2021

Answer To: To start, you're going to make an array that's full of random integers. This array should have a...

Arun Shankar answered on Jul 31 2021
133 Votes
#include
#include
#include
#include
using namespace std
;
const int SIZE = 20;
/* A function to print out the contents of
the array on the console. */
void print(int arr[SIZE])
{
for(int i=0;i cout< cout<}
/* A function to fill the array arr
with SIZE random numbers in the range 0-100 */
void fill(int arr[])
{
srand(time(0));
for(int i=0;i arr[i] = rand()%100;
}
/* A function to print a chart of the range of
numbers...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here