Hello All,
I was curious as to why the for loop in the example below, starts col = 1 instead of col = 0. Are they doing that just for this example because the largest value is stored in column 0 (the first column)? Also, I don't understand why the inequality sign is < instead of > because I am looking at it like:
If the largest value > the current value being evaluated in a particular iteration, then the largest value's address equals that column's memory location.
Since the sign is < though, I don't follow it's logic. Anyway, the example is below, any clarity offered is humbly appreciated.
The following for loop determines the largest element in row number 4:
I was curious as to why the for loop in the example below, starts col = 1 instead of col = 0. Are they doing that just for this example because the largest value is stored in column 0 (the first column)? Also, I don't understand why the inequality sign is < instead of > because I am looking at it like:
If the largest value > the current value being evaluated in a particular iteration, then the largest value's address equals that column's memory location.
Since the sign is < though, I don't follow it's logic. Anyway, the example is below, any clarity offered is humbly appreciated.
The following for loop determines the largest element in row number 4:
Code:
row = 4;
largest = matrix[row][0]; //Assume that the first element of the row is the largest.
for (col = 1; col < NUMBER_OF_COLUMNS; col++) if (largest < matrix[row][col])
largest = matrix[row][col];
Comment