wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Arrays

Total questions: 20

Worksheet time: 8mins

Name
Class
Date
1.

Unlike regular variables, __________ can hold multiple values.

a)

constants

b)

named constants

c)

arrays

d)

floats

2.

To access an array element, use the array name and the element's ___________.

a)

data type

b)

index

c)

value

d)

name

3.

Given the following declaration, where is the value 77 stored in the scores array?

int scores[] = {83, 62, 77, 97, 86}

a)

scores[0]

b)

scores[1]

c)

scores[2]

d)

scores[3]

4.

To pass an array as an argument to a function, pass the __________ of the array.

a)

contents

b)

size, expressed as an integer

c)

name

d)

value of the first element

5.

An element of a two-dimensional array is referred to by

a)

the array name followed by the column number of the element

b)

the row index of the element followed by the column index of the element

c)

a comma followed by a semicolon

d)

the row subscript (index) of the element followed by the array name

6.

Unlike regular variables, __________ can hold multiple values.

a)

constants

b)

functions

c)

arrays

d)

floats

7.
In an array, every element has the same
a)
data type
b)

subscript / index

c)
memory location
d)
all of the above
8.

Given the following declaration, where is the value 15 stored in the nums array?

int nums[] = {83, 15, 57, 87, 80}

a)

nums[0]

b)

nums[1]

c)

nums[2]

d)

nums[3]

9.

What is the proper declaration for an array that has 2 rows and 3 columns?

a)

type arr[2][2];

b)

arr[2][3] type;

c)

type arr[2][3];

d)

type arr[4][3];

10.

How can I store the value 10 into the second row, first column of array that is declared as int numbers[10][10]?

a)

int numbers[1][2] = 10;

b)

numbers[1][2] = 10;

c)

numbers[2][3] = 10;

d)

numbers[1][0] = 10;

11.

How do you initialize an array in C/C++?

a)

int arr[3] = (1,2,3);

b)

int arr(3) = {1,2,3};

c)

int arr[3] = {1,2,3};

d)

int arr(3) = (1,2,3){}

12.

Array elements are always stored in ________ memory locations.

a)

sequential

b)

Random

c)

Sequential and Random

d)

None of the above

13.

Which one is used to access the seventh element stored in arr?

a)

arr[6];

b)

arr[7]

c)

arr{6}

d)

arr{7}

14.

What are the first and last index of array ary?

int ary[9];

a)

1, 8

b)

0, 8

c)

0,9

d)

None of the above

15.

Which index of the array holds the value of 5?

for( int i=0; i<10; i++ )

numbers[i] = 2 * i + 1;

a)
1
b)
2
c)
3
d)
4
16.

Which of the following gives the second element in array named "foo" (an array with 100 elements)?

a)

foo[0];

b)

foo;

c)

&foo;

d)

foo[1];

17.

Arrays are structures that hold multiple variables of the _____________ data type

a)

int data type

b)

char data type

c)

same data type

d)

different data type

18.

What is the maximum number of dimensions an array in C/C++ may have?

a)

2

b)

8

c)

20

d)

50

e)

Theoratically no limit. The only practical limits are memory size and compiler used.

19.

Choose a correct statement.

a)

Size of an array can not be changed once it is created.

b)

Array element values can be changed any number of times

c)

To access Nth element of an array named students, use students[N-1]

d)

All options are correct

20.

How to initialize an array in C/C++?

Choose all the correct statement(s).

a)

int arr[3] = {1,2,3};

b)

int arr(3) = {1,2,3};

c)

int arr(3) = (1,2,3);

d)

int arr[3] = (1,2,3);

e)

int arr[3] = {0};