Font size
WorksheetsArrays
Total questions: 20
Worksheet time: 8mins
Unlike regular variables, __________ can hold multiple values.
constants
named constants
arrays
floats
To access an array element, use the array name and the element's ___________.
data type
index
value
name
Given the following declaration, where is the value 77 stored in the scores array?
int scores[] = {83, 62, 77, 97, 86}
scores[0]
scores[1]
scores[2]
scores[3]
To pass an array as an argument to a function, pass the __________ of the array.
contents
size, expressed as an integer
name
value of the first element
An element of a two-dimensional array is referred to by
the array name followed by the column number of the element
the row index of the element followed by the column index of the element
a comma followed by a semicolon
the row subscript (index) of the element followed by the array name
Unlike regular variables, __________ can hold multiple values.
constants
functions
arrays
floats
subscript / index
Given the following declaration, where is the value 15 stored in the nums array?
int nums[] = {83, 15, 57, 87, 80}
nums[0]
nums[1]
nums[2]
nums[3]
What is the proper declaration for an array that has 2 rows and 3 columns?
type arr[2][2];
arr[2][3] type;
type arr[2][3];
type arr[4][3];
How can I store the value 10 into the second row, first column of array that is declared as int numbers[10][10]?
int numbers[1][2] = 10;
numbers[1][2] = 10;
numbers[2][3] = 10;
numbers[1][0] = 10;
How do you initialize an array in C/C++?
int arr[3] = (1,2,3);
int arr(3) = {1,2,3};
int arr[3] = {1,2,3};
int arr(3) = (1,2,3){}
Array elements are always stored in ________ memory locations.
sequential
Random
Sequential and Random
None of the above
Which one is used to access the seventh element stored in arr?
arr[6];
arr[7]
arr{6}
arr{7}
What are the first and last index of array ary?
int ary[9];
1, 8
0, 8
0,9
None of the above
Which index of the array holds the value of 5?
for( int i=0; i<10; i++ )
numbers[i] = 2 * i + 1;
Which of the following gives the second element in array named "foo" (an array with 100 elements)?
foo[0];
foo;
&foo;
foo[1];
Arrays are structures that hold multiple variables of the _____________ data type
int data type
char data type
same data type
different data type
What is the maximum number of dimensions an array in C/C++ may have?
2
8
20
50
Theoratically no limit. The only practical limits are memory size and compiler used.
Choose a correct statement.
Size of an array can not be changed once it is created.
Array element values can be changed any number of times
To access Nth element of an array named students, use students[N-1]
All options are correct
How to initialize an array in C/C++?
Choose all the correct statement(s).
int arr[3] = {1,2,3};
int arr(3) = {1,2,3};
int arr(3) = (1,2,3);
int arr[3] = (1,2,3);
int arr[3] = {0};
