click below
click below
Normal Size Small Size show me how
CP2-Module 2
Arrays: Single Dimensional and Two Dimensional
Question | Answer |
---|---|
Which of the following statements is correct? double salary = balance(9); double salary = balance[9]: double salary : balance(9); double salary = balance[9]; | double salary = balance[9]; |
A series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier. Index Array Parameter Identifier | Array |
In C++, an Array is: All of the given Array elements are stored in memory in continuous or contiguous locations An array contains more than one element A group of elements of the same type | All of the given choices. |
What is the index number of the last element of an array with 20 elements? 18 0 20 19 | 19 |
Which of the following gives the memory address of the first element in an array? array[1]; array(2); array a. array[one]; | array |
Which of the following is NOT correct? int arr1[5]; Int arr1[5]; int arr1[] = {3,56,32,23,45}; int arr1[5] = {3,56,32,23,45}; | Int arr1[5]; |
If an array can store 10 values, what would be its last index? 9 11 8 10 | 9 |
What are the data types of Arrays? int double char All of stated data type | All of stated data type |
What is the output of the following code? #include <iostream> using namespace std; int main() { int a[] = {1,2,3,4}; int b[] = {5,6,7,8}; cout << a[0] << " " << b[0]; return 0; } Group of answer choices 1 5 | 1 5 |
What would be the output of the following code? #include <iostream> using namespace std; int main() { int myArray[] = {10,12,14,5,4}; int i=0; while(i<3) { cout << myArray[i] << " "; i++; | 10 12 14 |
Check the array below: int array[3][5] { { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10 }, { 11, 12, 13, 14, 15 } }; What’s the index of the array where it contains the value 10? | array [1][4] |
Which of the following is a two-dimensional array? int myArray2D[8][24]; int myArray2D[] = {8,24}; int myArray2D; int myArray2D(int x, int y) | int myArray2D[8][24]; |
What is the output of the following program? #include <iostream> using namespace std; int main () { int a[3][2] = { {0,0}, {1,2}, {2,4} }; for ( int i = 0; i < 3; i++ ) for ( int j = 0; j < 2; j++ ) { cout << a[ | 0 0 1 2 2 4 |
Check the array below: int array[3][5] { { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10 }, { 11, 12, 13, 14, 15 } }; What’s the index of the array where it contains the value 8? Group of answer choices array[1][1] | array [1][2] |
What is the index number of the last element of an array with 15 elements? 0 14 9 15 | 14 |
Which of the following is a two-dimensional array? char array[20]; int myArray [20][20]; array myArray [20][20]; int myArray[20]; | int myArray [20][20]; |
In the array is int arr[11][5], how many rows were created? 10 9 5 11 | 11 |
If you are going to create a 10x10 array named myTable, what would be your declaration? int myTable[10][10]; int myTables [10][10]; int myTable[] = {10,10}; Int myTable[10][10]; | int myTable[10][10]; |
In order to have an array with 5 rows and 10 columns, the correct declaration should be: int x[]={5,10}; int x[10][5]; int x(10)(5); int x[5][10]; | int x[5][10]; |
In order to have an array with 50 rows and 2 columns, the correct declaration should be: Group of answer choices int x[50][2]; int x[2][50]; int x[]={50,2}; int x[50]; | int x[50][2]; |