Learn C Programming

Lesson 2 of 9 · Arrays

Module 9 · Arrays

Traversal Patterns: Sum, Maximum, Count

Free with an accountReading

Zara logs the temperature of the freezer in her uncle's shop. A warm freezer spoils the ice cream, so she writes a function that returns the warmest reading.

Checking what this lesson needs for you…

What is inside Traversal Patterns: Sum, Maximum, Count

  1. A best that starts at 0
  2. Traversal: one visit per box
  3. The sum, and the average as a double
  4. The maximum starts from a[0]
  5. Keep the index of the best
  6. Count-if: how many pass
  7. Zara's edges: one value, all equal, all negative
  8. A second pass uses the first pass's answer