asked 150k views
1 vote
Which XXX and YYY will find the minimum value of all the elements in the array? Choices are in the form XXX/YYY.

int userVals [NUM_ROWS] [NUM_COLS];
int minVal = userVals [θ][θ];
for (i=0;i< NUM_ROWS;
for (j=0;j){
if (XXX) { NNUM_COLS; ++j){ YYY;
}
}
a. uservals [i]b. uservals [j]c. uservals [i][j]

asked
User MosesA
by
9.5k points

1 Answer

3 votes

Final answer:

The correct expressions to find the minimum value in a two-dimensional array are 'userVals[i][j]' for XXX and 'minVal = userVals[i][j]' for YYY, using a nested for loop to iterate over the elements.

Step-by-step explanation:

The question is asking for the correct expressions to find the minimum value of all the elements in a two-dimensional array in C/C++ programming. To find the minimum value in the array, you need to compare each element with the current minimum value and update the minimum value if a smaller element is found. The correct expressions to use are userVals[i][j] for XXX and minVal = userVals[i][j] for YYY. Here is the completed loop:

int minVal = userVals[0][0];
for (int i = 0; i < NUM_ROWS; ++i) {
for (int j = 0; j < NUM_COLS; ++j) {
if (userVals[i][j] < minVal) {
minVal = userVals[i][j];
}
}
}

This nested for loop iterates through all elements in the array and updates minVal whenever it finds an element smaller than the current minimum.

answered
User Edess Elder
by
7.5k points