Arrays Flashcards
Data structure that stores data of the same type
Array
Elements of an array are arranged ______
contiguously(in sequence)
Each element of an array can be considered as ________
one variable
Types of Arrays (2)
Static
Dynamic
Size of an array is defined during the array declaration
Static Array
Size of the array is determined during run time.
Uses a pointer
Dynamic Array
Static Array Syntax
<dataType> <arrName>[<size>];
</size></arrName></dataType>
Static Array Initialization
<dataType> <arrName>[<size>] = {<val1>, <val2>, ...};
</val2></val1></size></arrName></dataType>
Missing values of a static array will be given the value of ___
zero
Allows you to access the value of an element in an array given its index
Array Jndexing
Arrays have a ________ indexing; index starts at 0.
zero-based
Valid indices
- non- negative integers
- integers from 0 to size-1
Another way of accessing array values.
Done using asterisks and parentheses.
Pointer Arithmetic
Pointer Arithmetic Syntax
arrName[index] = *(arrName + index)
Uses pointers as well as the malloc() and free() functions
Dynamic Arrays