CIS 22B Quiz 1
What will the following code display? int numbers[4] = {99, 87}; cout << numbers[3] << endl;
0
What will the following code display? char table[88] = "how are you"; for (int i = 0; i < 3; i++) { cout << table[i]; }
how
An element of a two-dimensional array is referred to by
the row subscript of the element followed by the column subscript of the element
What will the following code display? int numbers[2][3] = {99, 87, 66, 55, 101}, sum = 0; for( int i = 0; i < 2; i++) sum += numbers[i][0]; cout << sum << " ";
154
What will the following code display? int sum = 0; int table[3][4] = { { 2, 3 },{ 7, 9, 2 },{ 1 } }; for (int i = 0; i < 3; i++) { sum+= table[1][i] ; } cout << sum;
18
What will the following code display? char table[3][4] = { 'a', 'b', 'c', 'd', 'e' }; for (int i = 0; i < 3; i++) { cout << table[0][i]; }
abc
A two-dimensional array can have elements of data type(s).
one
A two-dimensional array can be viewed as
rows and colums
What will the following code display? int numbers[2][3] = {99, 87, 66, 55, 101}; cout << numbers[1][2] << endl;
0
What does the following code do? const int SIZE1, SIZE2 = 3; int arr[SIZE1][SIZE2] ; for (int i = 1; i < SIZE1; i++) { for (int j = 0; j < SIZE2; j ++) arr[ i ] [ j ] = 6 ; }
an error will occur when the code runs