Search Header Logo
DCS1101 - Week 9 (Arrays)

DCS1101 - Week 9 (Arrays)

Assessment

Presentation

Computers

University

Medium

Created by

Yasmin Basiran

Used 1+ times

FREE Resource

38 Slides • 10 Questions

1

media

2

media

3

4

media

5

media

6

media

7

media

8

media

9

media

10

media

11

media

12

media

13

Multiple Choice

Array indexing begins with what number?

1
0
2
-1
3
1
4
5

14

Multiple Choice

Which declaration is correct?

1

int num[5];

2

int[5] num;

3

num int[5];

4

array int num(5)

15

Multiple Choice

What will this output show if
int bats = {3,5,7}

cout << bats[1];

1
Output: 5
2
Output: 3
3
Output: 7
4

Output: Error

16

media

17

media

18

media

19

media

20

media

21

media

22

media

23

media

24

media

25

Multiple Choice

Default values in uninitialized local array?

1
Uninitialized local arrays have indeterminate values.
2
Uninitialized local arrays have fixed values assigned.
3
Uninitialized local arrays contain default values of zero.
4
Uninitialized local arrays are always zeroed out.

26

Draw

Draw a spooky array called ghosts[5] and label each index with a different ghost.

27

Draw

Draw a memory box diagram showing how pumpkin[4] = 13 is stored.

28

media

29

media

30

media

31

media

32

media

33

media

34

media

35

media

36

media

37

media

38

media

39

media

40

Open Ended

Why is accessing out-of-range elements dangerous

41

media

42

media

43

media

44

media

45

Multiple Choice

Which of the code prints an entire row of arrays?

1
Use print(array[row_index]) to print an entire row of arrays.
2
print(array[row_index].toString()) outputs the row as a string.
3
print(array[row_index:]) will show the row and the following rows.
4
Use print(array[row]) to display the entire array.

46

Multiple Choice

To modify array inside function, what is the best practice?

1
Return a new array instead of modifying the original
2
Pass the array by reference or use mutable data structures.
3
Use global variables to modify the array
4
Pass the array by value

47

Open Ended

If you were storing potion recipes, would a 1D or 2D array be better? Why?

48

media
media

Show answer

Auto Play

Slide 1 / 48

SLIDE