Arrays and Pointers Flashcards
Define an array
A series of elements of only one data type
What the range of values of array indices, for an array of length n?
0 to n-1
What happens if you do not initialize an array at all?
The compiler stores each element of the array with a random garbage value
What happens if you partially initialize an array?
The remaining elements of the array store zero as their value
what are the values of each element in an array scores declared as follows:
arr[] = {[7] = 12};
(or is there a compilation error?)
arr[0] = 0,
arr[1] = 0,
arr[2] = 0,
arr[3] = 0,
arr[4] = 0,
arr[5] = 0,
arr[6] = 0,
arr[7] = 12,
arr[8+] = garbage values
what are the values of each element in an array scores declared as follows:
arr[11] = {[7] = 12};
(or is there a compilation error?)
arr[0] = 0,
arr[1] = 0,
arr[2] = 0,
arr[3] = 0,
arr[4] = 0,
arr[5] = 0,
arr[6] = 0,
arr[7] = 12,
arr[8] = 0,
arr[9] = 0,
arr[10] = 0,
arr[11+] = garbage values
what are the values of each element in an array scores declared as follows:
arr[11] = {[7] = 12, [11] = 5};
(or is there a compilation error?)
Compilation error