San Diego State University logo
ME 203

Module 4.1 - Array Basics


Notice in average1.c that we have 3 separate loops; one does the reading, one does the printing, and the last does the averaging.

  • Can you contract these calculations into just 2 loops, one that does the data extraction, and the next that does both printing and averaging?
    • One aspect of for loops that may help is that the variable initialization portion of the for clause is not limited to initializing just one variable.
  • What about distilling this program into just 1 loop, which does all the reading, printing an averaging?

Think about how you might go about doing the above and discuss it with your classmates.


For another take on understanding arrays, check out HowStuffWorks.com chapter on Arrays.

Another good resource is Cprogramming.com; check out their lesson on Arrays as well.

Continue to the Next Module on Arrays ->

Website by Joshua Bleier