Write a function that will generate an array of random numbe

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

Solution

#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++)           {                     cout << arr[i];          } }
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 maxi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site