Lecture 7 Flashcards

1
Q

Array

A

Group of variables with the same name of the same type. Each number has a unique way of identifying it.

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

Declaring an array

A

Type name[size];
Or
Type name[] = {number, number, … }

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

How arrays store data

A

Declaring an array sets aside as many “boxes” as the size of the array. Each element has it’s own box. Each box is referred to with a number, starting at 0, called an index.

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

Element

A

Individual value in an array

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

Index

A

Number referring to an element

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

What is considered a variable in an array

A

The entire array is considered the variable

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

Sub

A

How to refer to an individual element. Array name followed by the index for the element: e.g. X sub 3

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

Indexing an array

A

Accessing a single element in an array by using it’s index

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

Tips for initializing array size

A

Set it larger than expected if size is unknown, but not so large too much memory is used.

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

Initializing an array

A

Type name[size] = {number, …}
Or
Type name[] = {number, …}
^ will initalize size to number of elements

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

Tips for initializing an array

A

Set unknown elements to 0

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

Parallel arrays

A

Two or more arrays who’s elements at the same index are related.

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

Multidimensional array

A

An array with more than one set of numbers

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

How to initalize the size of a multidimensional array

A

Type name[size][size];

Can add more than one size by adding another set of square brackets with the size.

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

How to loop through values

A

Nested loops

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

Array bounds

A

The boxes that are included in the array

17
Q

Out-of-bounds error

A

When an index is called that is out of bounds of an array

Can get a random number or the computer may crash. No error will be received.