Arrays and Pointers Flashcards

1
Q

Define an array

A

A series of elements of only one data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What the range of values of array indices, for an array of length n?

A

0 to n-1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens if you do not initialize an array at all?

A

The compiler stores each element of the array with a random garbage value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens if you partially initialize an array?

A

The remaining elements of the array store zero as their value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are the values of each element in an array scores declared as follows:
arr[] = {[7] = 12};
(or is there a compilation error?)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what are the values of each element in an array scores declared as follows:
arr[11] = {[7] = 12};
(or is there a compilation error?)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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?)

A

Compilation error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly