click below
click below
Normal Size Small Size show me how
F2 ComProg
| 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]; |
| 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 |
| What is the index number of the last element of an array with 20 elements? | 19 |
| What is the output of the following code? #include <iostream> using namespace std; int main() { char grade[] = {'A','B','C'}; cout << "GRADE = " << grade[0]; return 0; } | GRADE = A |
| Which of the following best describes an array? | Container of objects of similar types |
| 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 |
| Which of the following correctly declares an array? | double prices[5]; |
| Which of the following is NOT true? | You can change the array size anytime. |
| What is the index number of the last element of an array with 50 elements? | 49 |
| If the array has a syntax of data_type array_name[x][y]; What does y represent? | columns |
| 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 order to have an array with 11 rows and 13 columns, the correct declaration should be: | int x[11][13]; |
| Which of the following is a two-dimensional array? | int myArray [20][20]; |
| In an array, int a[3][2], what is the last index value of the column? | 1 |
| In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; how many rows are there? | 3 |
| Which of the following is a two-dimensional array? | int myArray2D[8][24]; |
| 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] |
| In the array is int x[3][4], how many columns were created? | 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? | array [1][2] |
| In a single dimension array, the starting index is always _____________. | 0 |
| 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++; | 90.5 92.5 96.5 |
| Which of the following statements is correct? | double salary = balance[9]; |
| Which of the following statements is correct? | double average_grade = (quiz[0]+quiz[1]+quiz[2])/3; |
| Which of the following is correct about arrays? | An array size cannot be changed once it is created To access the Nth element of an array students, used students[n-1] as the starting index is 0 All of the given Array element values can be changed any numbers of times |
| What are the data types of Arrays? | char double All of stated data type int |
| An array starts with ___________ | 0 |
| 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 |
| In the array int x[2][5], how many rows were created? | 2 |
| In the array is int x[10][6], how many columns were created? | 6 |
| If you will be making a table of values, composed of 3 rows and 5 columns, what would be the array declaration? | int a[3][5]; |
| A two-dimensional array can be described as: | A table of values ? |
| What is the output of the given program? #include <iostream> using namespace std; int main() { int a[2][2] = {{2,4},{6,8}}; int i, j; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) cout << a[i][j | 2 4 6 8 |
| An array composed of 6 rows and 2 columns, what would be the array declaration? | int a[6][2]; |
| In the array is int x[100][50], how many columns were created? | 50 |
| In a given array int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}}; how many rows are there? | 3 |