click below
click below
Normal Size Small Size show me how
COMPROG MODULE 2
| Question | Answer |
|---|---|
| How do you initialize an array in C+? | int arr [3] = {1, 2, 3}; |
| Which of the following accesses the seventh element stored in an array? | array [6] |
| In C++, an Array is: | Array is a collection of elements of the same type placed in contiguous memory locations that can be individually referenced by using an index to a unique identifier |
| A one dimensional array is also known as ___________________. | Single Dimension Array |
| What is the correct array declaration? | int arr2 [15]; |
| What is the index number of the last element of an array with 29 elements? | 28 |
| What is the output of the program? #include <iostream> using namespace std; int main() { int myArray[] = {1,2,3,4,5}; for (int i = 0; i<5; i++) { cout << myArray[i] << " "; i++; } } | 1 3 5 |
| If the array has a syntax of data_type array_name[x][y]; What does y represent? | COLUMNS |
| 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; } | 1 5 |
| What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { char str[] = "ABCDE"; for (int i = 0 ; i<3;i++ ) { cout << str[i]; } return 0; } | ABC |
| Which of the following statements is correct? | double salary = balance [9]; |
| Which of the following correctly declares an array? | float prices [3]; |
| Which of the following correctly declares an array? | double prices [5]; |
| 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. | Array |
| . What is the output of the program? #include <iostream> using namespace std; int main() { int myArray[] = {2,4,6,8,10,12}; for (int i = 0; i<6; i++) { cout << myArray[i] << " "; } } | 2 4 6 8 10 12 |
| If an array can store 100 values, what would be the first index? | 0 |
| What is the index number of the last element of an array with 20 elements? | 19 |
| In the array is int x[5][6], how many columns were created? | 6 |
| 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? | array [1][2] |
| What is the output of the program? #include <iostream> using namespace std; int main () { int a[5][2] = { {0,0}, {1,2}, {2,4}, {3,6}, {4,8}}; int sum = a[2][0]+a[1][1]; cout << sum << endl; return 0; } | 4 |
| Which of the following is a two-dimensional array? | int myArray [20][20] |
| Which of the following is a two-dimensional array? | int myArray[13][11]; |
| In the array is int x[15][8], how many rows were created? | 15 |
| In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; what is index of 5? | x [1][1] |
| It is an array that consists of more than one row and more than one column. | 2-Dimensional Array |
| What is the output of the following code? #include <iostream> using namespace std; int main() { char grade[] = {'A','B','C'}; int n = grade[0]; cout << "GRADE = " << grade[0] << " " << n ; return 0; } | GRADE = A 65 |
| What is the output of the program? #include <iostream> using namespace std; int main() { int myArray[] = {1,2,3,4,5,6}; for (int i = 0; i<6; i++) { i++; cout << myArray[i] << " "; } } | 2 4 6 |
| What is the output of the program? #include <iostream> using namespace std; int main() { int myArray[] = {1,2,3,4,5,6}; for (int i = 0; i<6; i++) { cout << myArray[i] << " "; } } | 1 2 3 4 5 6 |
| In the array int x[3][4], how many rows were created? | 3 |
| In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; how many columns are there? | 4 3 |
| In order to have an array with 11 rows and 13 columns, the correct declaration should be: | int x[11][13]; |
| It refers to a table of rows and columns | Matrix |
| 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 |
| What is the correct definition of an array? | What is the correct definition of an array? |
| 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] |
| In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; what is index contains 3? | x [0][3]; |
| What is the output of the program? #include <iostream> using namespace std; int main() { int a[2][2] = {{1,2},{3,4}}; int i, j; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) cout << a[i][j]; return 0; } | 1 2 3 4 |
| A one-dimensional array most resembles what type of structure? | A single row of data |
| In a single dimension array, the starting index is always _____________. | 0 |
| What is the index number of the last element of an array with 50 elements? | 49 |
| If you will be making a table of values, composed of 3 rows and 3 columns, what would be the array declaration? | int a [3][3]; |
| In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; What is index of 7? | x [1][3]; |
| If you are going to create a 10x10 array named myTable, what would be your declaration? | int myTable[10][10]; |
| What is the output of the following code? #include <iostream> using namespace std; int main() { int arr[3] = {1,2,3}; for (int i = 0; i < 3 ; i++) cout << arr[i] << " "; return 0; } | 1 2 3 |
| 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 12? | Array [2][1] |
| In the array is int x[100][50], how many rows were created? | 100 |
| Which of the following best describes an array? | Container of objects of similar types |
| Which of the following correctly accesses the seventh element stored in an array named box with 100 elements? | box [6]; |
| In order to have an array with 2 rows and 9 columns, the correct declaration should be: | int x [2][9]; |
| In the array is int x[13][11], how many columns were created? | 11 |
| In the array is int x[10][6], how many columns were created? | 6 |
| What is the index number of the last element of an array with 9 elements? | 8 |
| What is the output of the following code? #include <iostream> using namespace std; int main() { double marks[3] = {90.5, 92.5, 96.5}; int a=0; while(a<3) { cout << marks[a] << " "; a++; } return 0; } | 90.5 92.5 96.5 |
| What is the output of the given code? #include <iostream> using namespace std; int main() { int a[3] = {10,12,14}; int i=0; while(i<3) { cout << a[i] << " "; i++; } } | 10 12 14 |
| In order to have an array with 50 rows and 2 columns, the correct declaration should be: | int x [50][2]; |
| What are the data types of Arrays? a. int, b. double, c. All of stated data type, d. char | All of stated data type |