Question: C++ hand trace help.... perform a hand-trace of the code by making a table of values by hand or using Microsoft Words table feature. Write
C++ hand trace help....
perform a hand-trace of the code by making a table of values by hand or using Microsoft Words table feature. Write down the contents of the array after each pass of the outside for loop. Keep track of all changing variales.
const int SIZE = 6;
int main() {
int minIndex, minValue,
numValues = SIZE;
int a[SIZE] = {3, 2, 1, 5, 6, 4};
for (int j = 0; j < numValues - 1; j++) {
minIndex = j;
minValue = a[j];
for (int i = j + 1; i < numValues; i++)
if (a[i] < minValue) {
minValue = a[i];
minIndex = i;
}
a[minIndex] = a[j];
a[j] = minValue;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
