Answer:
Following are th program in the C++ Programming Language.
#include <iostream>//set Header files
using namespace std;//set namespace
//define main function
int main()
{
//set integer constants variable
const int NUM_ROWS = 2;
//set integer constants variable
const int NUM_COLS = 2;
//set integer type array
int milesTracker[NUM_ROWS][NUM_COLS];
//set integer type variable and initialize to 0
int i = 0;
//set integer type variable and initialize to 0
int j = 0;
//set integer type variable and initialize to -99
int maxMiles = -99;
//set integer type variable and initialize to -99
int minMiles = -99;
//initialize the value in the two dimensional array
milesTracker[0][0] = -10;
milesTracker[0][1] = 20;
milesTracker[1][0] = 30;
milesTracker[1][1] = 40;
//here is the solution
maxMiles = milesTracker[0][0];
minMiles = milesTracker[0][0];
/*set for loop to find the minimum miles and maximum miles*/
for (i = 0; i < NUM_ROWS; i++)
{
for (j = 0; j < NUM_COLS; j++)
{
//set if condition for maxMiles is the bigger than
if (milesTracker[i][j] > maxMiles)
//initialize milesTracker[i][j] to maxMiles
maxMiles = milesTracker[i][j];
//set if condition for minMiles is the smaller than
if (milesTracker[i][j] < minMiles)
//initialize milesTracker[i][j] to maxMiles
minMiles = milesTracker[i][j];
}
}
//print output
cout << "Min miles: " << minMiles << endl;
//print output
cout << "Max miles: " << maxMiles << endl;
return 0;
}
<u>Output:</u>
Min miles: -10
Max miles: 40
Explanation:
Here, we define the main method and inside it:
- set two constant integer type variable and initialize to 2
- set integer type two-dimensional array and pass constant variables in it.
- Set two integer type variable and initialize to 0 then, again set two integer type variable and initialize to -99.
- Initialize the values in the two-dimensional array.
- Set two for loop for the two-dimensional array to find the minimum and maximum miles.
- Set two if condition to find bigger or smaller miles.
Finally, print the maximum and the minimum miles then, return 0.