Array Vocabulary


TOPICS:

1. array 8. initializer list
2. aggregate 9. index
3. scalar 10. subscript
4. element 11. one-dimentional array
5. array type 12. two-dimentional array
6. array size 13. matrix
7. array initializer 14. null char('\0')


1. array

An array is an aggregate data structure, an ordered collection of elements -- all of the same type.

An array is a group of memory locations related by the fact that they all have the same name and same type. We refer to individual elements of the array by specifying the name of the array and the position of the particular element of the array.

Back to the Topic Index


2. aggregate

a group of massed things collected together and considered as one whole larger object.

Back to the Topic Index


3. scalar

A scalar object is a single object of single size. Any number ("3") is a scalar object. A coordinate point -- (x,y) -- has two values and indicates size in two directions, two-dimensions. The coordinate point is NOT scalar.

C has lots of types: floats, ints, chars, doubles, etc. All of these are scalar types.

Structs and Arrays are NOT scalar types.

Back to the Topic Index


4. element

An element of an array is one of the "collection" that the array defines:
a[0] (read: "a sub 0")
is one element in the array a.

Back to the Topic Index


5. array type

Arrays have a type associated with them. You can have an array of ints, an array of floats, an array of chars, etc. The array type is INT or FLOAT or CHAR. Each "array of type" is distinct. Just as floats are distinct from chars.

Think of your array of integers as "an array of type int" and your array of floats as "an array of type float" when trying to figure out how to relate the two different arrays.

Back to the Topic Index


6. array size

Arrays are "static": They remain the same size throughout the program's execution.

An array has a defined size.
If you declare an array of integers:

int integer_array[30]
This array has 30 elements. However, their positions number 0 - 29.

Back to the Topic Index


7. array initializer

An array can have an initializer like any other C variable.

For example:
int x = 0;
Defines an integer x with an initial value of 0.

int A[9] = {0};
Defines an integer array A with the initial value of 0 for all of its elements.

int A[9] = {21};
Defines an integer array A with an initial value of 21 for its first element and 0 for all the rest.

int A[9] = {0,1,2,3,4,5,6,7,8};
Defines an integer array A with initial values as follows:

Element Number Array Position Initial Value
1 0 0
2 1 1
3 2 2
4 3 3
5 4 4
6 5 5
7 6 6
8 7 7
9 8 8

Back to the Topic Index


8. initializer list

The integer array below has han initializer list:

int A[9] = {0,1,2,3,4,5,6,7,8};
The Initializer List is "{0,1,2,3,4,5,6,7,8}"

Back to the Topic Index


9. index

An array index is just like an variable index in math. You can talk about a set of values, x, each with a subscript i, as i goes from 1 to n.

Arrays work on a similar principle. You have an array, A. It's elements are the subscript positions they hold in the array.

The First Element of any array in C is the ZEROTH element.

Element Number Array Position Element Name
1st 0 a[0] ("a sub 0")
2nd 1 a[1] ("a sub 1")
3rd 2 a[2] ("a sub 2")
4th 3 a[3] ("a sub 3")
5th 4 a[4] ("a sub 4")
nth n a[n-1] ("a sub n-1")
n+1st n a[n] ("a sub n")

Notice that the ith element of the array is in position i-1.

Back to the Topic Index


10. subscript

Just like subscripting numbers in math. Another word for index.

The subscript for x1 is 1 (math).
The subscript for a[i] is i (C).

Back to the Topic Index


11. one-dimentional array

You can think of a one-dimentional array in C as a set of elements all lined up in a row or column. A row of elements is an array. A column of elements is also an array of elements.

Back to the Topic Index


12. two-dimentional array

Think of this as a piece of graph paper. It has rows and columns. It has TWO dimensions. A two dimentional array is often called a matrix.

Back to the Topic Index


13. matrix

A two-dimentional array made up of rows and columns.

Back to the Topic Index


14. null char('\0')

The null character is a special character that is written : '\0'

It is used in the string library functions to indicate the end of a string. Sometimes you need to add it. Sometimes it's added for you. It's your responsibility to be sure it's there if you going to use the string functions.

Back to the Topic Index


Back to the Top of this Page


Back to the Top of this page


[Back to the Index]

graphics images Copyright 1998-2003 Elizabeth Fraley HTML code copyright 1998-2003 Elizabeth Fraley. Permission is given to provide these pages in their original, unaltered form online for educational purposes. They may not be republished or included on a CDROM, disk or other media or with any published work without the express permission of the copyright holder (this includes FAQ books).