Write a function that will generate an array of random numbers. It needs to: tak
ID: 3791052 • Letter: W
Question
Write a function that will generate an array of random numbers. It needs to:
take 3 integers as parameters
The first is the minimum value
the second is the maximum value
the third is the size of the new array
create a dynamically allocated array of the correct size generate a random number (between min and max) for each element in the array
return a pointer to the array
Create a main() function that tests the above function and displays the values in the random array.
Do not use array notation inside the function. Use pointer notation only. Do not use any type of operation such as cstdlib.h , ctime.h or cstdlib
This is C++. Please make sure the answer is readable and executable. Thanks
Explanation / Answer
#include #include using namespace std; //prototypes void printFunc(int[]); void fillFunc(int[]); int main() { int random[25]; //0-24 is 25 remember array indeices srand((unsigned)time(NULL)); fillFunc(random); printFunc(random); return 0; } void fillFunc(int arr[]) { for (int i = 1; i < 25; i++) { arr[i] = 1+ rand() % 10; } } void printFunc(int arr[]) { for (int i = 1; i < 25; i++) { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.