Guided Notes

Arrays

Declaring and initializing arrays, indexing and bounds, looping over arrays, finding max/min/average, and two-dimensional arrays.

What an array is

Slide 1 / 5

An array stores a fixed number of values of the same type, side by side in memory: int scores[5] = {90, 78, 85, 92, 67};

• Indexes start at 0: scores[0] is 90, scores[4] is 67. • The size is fixed when declared. • int nums[5] = {0}; sets every element to 0. • Leave the size out and let C count: int primes[] = {2, 3, 5, 7}; • Number of elements: sizeof(scores) / sizeof(scores[0]).

← Loops