Question: The following code sets up an array of 30 random integers in the range [0, 99]. Compute and print out the statistical mean and range
The following code sets up an array of 30 random integers in the range [0, 99]. Compute and print out the statistical mean and range of the data set:
Starter Code:
#include#include #include constexpr size_t SIZE = 30; static int getRandomNumber(); static void printArray(int data[], size_t size); int main() { int numbers[SIZE]; for (auto i = 0; i < SIZE; i++) { numbers[i] = getRandomNumber(); } printArray(numbers, SIZE); // TODO: print out the mean and range of the data set } static int getRandomNumber() { static std::mt19937 gen{ std::random_device{}() }; static std::uniform_int_distribution dist{ 0, 99 }; return dist(gen); } static void printArray(int data[], const size_t size) { std::cout << "["; for (auto i = 0; i < size; i++) { std::cout << data[i] << ((i == size - 1) ? "" : ", "); } std::cout << "] "; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
