11- defining arrays, arrays with for-loops, passing arrays as arguments Flashcards
Aggregate construct
a construct that allows manipulation of multiple entities as a single entity
Array
a collection of variables called (array) elements or indexed variables
array is an aggregate construct
Name of the array
the same for all elements of single array
Index (or subscript)
different for element, put in square brackets []
(array) base type
type of the array elements
all elements have the same type
array size
number of elements
array declaration
int score[5];
the number in brackets: 5 is array size
the indexes start from 0. Above statement declares the following variables:
score[0], score[1], score[2], score[3], score[4]
note, score[5] is not there!
Scalar variable
non array (regular) variable
out-of-range error
referring to index that is not in array
it is a logical error (bug/run-time error) with unpredictable consequences.
these are both out-of-range errors a[10]=55; a[myvar]=5;
const
const type modifier specifies that the parameter shall not be modified in the function
that is, it turns accidental value change into compile-time error