
478 CHAPTER 8 Single-Dimensional Arrays
Figure 8.7
Calculating the Total of
All Elements
8.3.4 Finding Maximum or Minimum Values
Suppose we want to find the month that has the lowest bill. That would
require finding a minimum value in the array and noting its index. Simi-
larly, to find a month with the highest bill, we would need to find a maxi-
mum value in the array and note its index.
To find a maximum or minimum value in an array, we use a variation of
the standard for loop. Example 8.6 finds the highest array value and its
array index for our cellBills array of monthly cell bills.
1 /* Finding the maximum array value
2 Anderson, Franceschi
3 */
4
5