Answer:
#include <iostream>
#include <cstdlib>
using namespace std;
const int MIN_VALUE = 15;
const int MAX_VALUE = 20;
void fillArray(int arr[], int n) {
// fill up the array with random values
for (int i = 0; i < n; i++) {
arr[i] = rand() % (MAX_VALUE - MIN_VALUE + 1) + MIN_VALUE;
}
}
void displayArray(int arr[], int n) {
for (int i = 0; i < n; i++) {
cout << i << ": " << arr[i] << endl;
}
}
void main()
{
int myArray[10];
int nrElements = sizeof(myArray) / sizeof(myArray[0]);
fillArray(myArray, nrElements);
displayArray(myArray, nrElements);
char choice;
do {
cout << "[P]osition [R]everse, [A]verage, [S]earch, [Q]uit ";
cin >> choice;
choice = toupper(choice);
switch (choice) {
case 'P':
displayArray(myArray, nrElements);
break;
}
} while (choice != 'Q');
}
Step-by-step explanation:
Here's a start. Now can you do the rest? ;-)