In class today, the following topics were covered:
- Another looping example, solving the isPrime problem using a for loop
- Example programs demonstrating array addressing and arrays as parameters to functions
- Discussion that variables, including arrays, in C++ were not initialized by default
- The notion that it is possible to allocate a particular sized array (give it a capacity) but use less than the available space (so its effective size is less than its capacity)
- Problem scenarios in which multi-dimensional arrays are applicable
- The syntax for declaring, indexing, and (awkwardly) using as function parameters multi-dimensional arrays
- The notion that we should consider a 2-d array as really an array of arrays.
Here are all of the programs we looked at in class:
- arrayAddresses.cpp (using the address operator to look at the memory layout of arrays)
- averageGrades.cpp (simple use of array for averaging 5 grades)
- averageGradesFunctionBased.cpp (passing whole arrays as function parameters, writing functions that are “general” in terms of array specifics)
- averageGradeArbitraryArray.cpp (allowing arrays up to a max capacity, but not requiring the full capacity be used)
- 2DArrayAddresses.cpp (using the address operator to look at the memory layout of 2d arrays [differences in moving up a row vs. column])
- 2DArrayFunctionsAwkward.cpp (passing multi-dimensional arrays as parameters to functions)
- ticTacToe.cpp (a simple ticTacToe program making use of a 3x3 2d array)