121 Week 7 - 2D Arrays Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

2D array

A

An array where each element in the array is another array.
Created in C by: datatype arrayName[int][int];

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

Indexing a 2D array

A

You can access individual elements in a 2D array using 2 sets of square brackets. The first for the “row” and the second for the “column”
e.g., arrayName[2][3]

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

Pros of 2D arrays

A

Can use a single name to represent multiple data items of the same type.
Random access so very fast to access an individual item.

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

Cons of 2D arrays

A

Arrays are fixed sizes
Insertion and deletion from arrays are costly

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

Constants

A

Similar to a variable but once it is defined, its value cannot be changed - it is kept constant. constant names are conventionally in uppercase.
#define CONST_NAME value

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

Benefits of constants

A

Can use the constant to represent a value which can be used throughout the code. If this value needs to be different, only change 1 line of code - the constant definition.

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