Answer:
The required part of the program in C++ is as follows:
int *ptr;
int *myNums = new int(100);
srand (time(NULL));
for (int i = 0; i < 100; i++) {
myNums[i] = rand() % 200 + 2; }
ptr = myNums;
cout << "Output: ";
for (int i = 0; i < 100; i++) {
cout <<*(ptr + i) << " "; }
delete[] myNums;
Step-by-step explanation:
This declares a pointer variable
int *ptr;
This declares the dynamic array myNums
int *myNums = new int(100);
This lets the program generate different random numbers
srand (time(NULL));
This iterates through the array
for (int i = 0; i < 100; i++) {
This generates an integer between 2 and 200 (inclusive) for each array element
myNums[i] = rand() % 200 + 2; }
This stores the address of first myNums in the pointer
ptr = myNums;
This prints the header "Output"
cout << "Output: ";
This iterates through the pointer
for (int i = 0; i < 100; i++) {
Print each element of the array, followed by space
cout <<*(ptr + i) << " "; }
This deletes the dynamic array
delete[] myNums;