7. Chapter 7 Arrays - compscisi/Programming-Fundamentals-1-SI GitHub Wiki

Array Terminology

In the definition:

int tests[5];

  • int is the data type of the array elements
  • tests is the name of the array
  • 5, in [5], is the size declarator. It shows the number of elements in the array.
  • The size of an array is (number of elements) * (size of each element)

Basic Vocabulary

Term Definition
Size Declarator Only used when defining the size of the array for how many elements you need
Size of the Array Total number of bytes allocated for the array

Key Facts

  • When using an initialization list you don’t need to use a size declarator
    • An example where n is the size declarator (total number of elements in the array)

      Size Declarator Referencing with an Index
      int arr[n]; arr[n-1];
  • One way to initialize an array:
    •  for (int n = 1; n <= SIZE; n++)
       {
          cout << “Enter value for element ” << n << endl;
          cin >> Array[n - 1];
       }