EmSAT Achieve Exam  >  EmSAT Achieve Tests  >  C++ for EmSAT Achieve  >  Test: 2D Arrays - EmSAT Achieve MCQ

Test: 2D Arrays - EmSAT Achieve MCQ


Test Description

20 Questions MCQ Test C++ for EmSAT Achieve - Test: 2D Arrays

Test: 2D Arrays for EmSAT Achieve 2024 is part of C++ for EmSAT Achieve preparation. The Test: 2D Arrays questions and answers have been prepared according to the EmSAT Achieve exam syllabus.The Test: 2D Arrays MCQs are made for EmSAT Achieve 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: 2D Arrays below.
Solutions of Test: 2D Arrays questions in English are available as part of our C++ for EmSAT Achieve for EmSAT Achieve & Test: 2D Arrays solutions in Hindi for C++ for EmSAT Achieve course. Download more important topics, notes, lectures and mock test series for EmSAT Achieve Exam by signing up for free. Attempt Test: 2D Arrays | 20 questions in 40 minutes | Mock test for EmSAT Achieve preparation | Free important questions MCQ to study C++ for EmSAT Achieve for EmSAT Achieve Exam | Download free PDF with solutions
Test: 2D Arrays - Question 1

What is a 2D array?

Detailed Solution for Test: 2D Arrays - Question 1

A 2D array is an array of arrays, where each element in the array is itself an array. It represents a table or matrix-like structure.

Test: 2D Arrays - Question 2

How do you declare a 2D array in C++?

Detailed Solution for Test: 2D Arrays - Question 2

In C++, the syntax for declaring a 2D array is 'int array[][]'; or 'int array[rowSize][colSize]';, where 'rowSize' and 'colSize' are the desired sizes of the array.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: 2D Arrays - Question 3

What is the syntax for accessing an element in a 2D array?

Detailed Solution for Test: 2D Arrays - Question 3

To access an element in a 2D array, we use the syntax 'array[row][column]', where 'row' and 'column' are the indices of the desired element.

Test: 2D Arrays - Question 4

How do you initialize a 2D array with values in C++?

Detailed Solution for Test: 2D Arrays - Question 4

To initialize a 2D array with values in C++, we use the syntax 'int array[][] = {{1, 2, 3}, {4, 5, 6}};', where each inner array represents a row and the values inside the inner arrays represent the elements of each row.

Test: 2D Arrays - Question 5

What is the maximum number of dimensions a C++ array can have?

Detailed Solution for Test: 2D Arrays - Question 5

C++ does not impose a maximum limit on the number of dimensions an array can have. However, the practical limit depends on the available memory and the capabilities of the compiler.

Test: 2D Arrays - Question 6

How can you pass a 2D array to a function in C++?

Detailed Solution for Test: 2D Arrays - Question 6

To pass a 2D array to a function in C++, you can pass the entire array as a single argument. The function signature would look like 'void functionName(int array[][colSize])'.

Test: 2D Arrays - Question 7

Which of the following operations can be performed on 2D arrays?

Detailed Solution for Test: 2D Arrays - Question 7

In C++, you can perform addition and subtraction operations on 2D arrays by applying the respective operations to each corresponding element in the arrays.

Test: 2D Arrays - Question 8

What is the time complexity of accessing an element in a 2D array by its index?

Detailed Solution for Test: 2D Arrays - Question 8

The time complexity of accessing an element in a 2D array by its index is constant, O(1), as the index directly determines the memory location of the element.

Test: 2D Arrays - Question 9

How can you find the number of rows in a 2D array in C++?

Detailed Solution for Test: 2D Arrays - Question 9

In C++, there is no direct way to find the number of rows in a 2D array. You need to keep track of the row size separately or use a row size constant if the size is fixed.

Test: 2D Arrays - Question 10

What is the memory layout of a 2D array in C++?

Detailed Solution for Test: 2D Arrays - Question 10

In C++, elements in a 2D array are stored in a row-major order, meaning that the elements of each row are stored in a contiguous block of memory.

Test: 2D Arrays - Question 11

What will be the output of the following code?
#include <iostream>

int main() {
   int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
   std::cout << arr[1][2];
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 11

The code initializes a 2D array 'arr' with values. The expression 'arr[1][2]' accesses the element at row 1 and column 2, which is 6. The output will be 6.

Test: 2D Arrays - Question 12

What will be the output of the following code?
#include <iostream>

int main() {
   int arr[2][2] = {{1, 2}, {3, 4}};
   std::cout << arr[1][1] + arr[0][0];
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 12

The code initializes a 2D array 'arr' with values. The expression 'arr[1][1] + arr[0][0]' adds the values at row 1, column 1 (which is 4) and row 0, column 0 (which is 1). The result is 5, and the output will be 5.

Test: 2D Arrays - Question 13

What will be the output of the following code?
#include <iostream>

int main() {
   int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
   std::cout << arr[1][2] - arr[0][1];
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 13

The code initializes a 2D array 'arr' with values. The expression 'arr[1][2] - arr[0][1]' subtracts the value at row 0, column 1 (which is 2) from the value at row 1, column 2 (which is 6). The result is 4, and the output will be 4.

Test: 2D Arrays - Question 14

What will be the output of the following code?
#include <iostream>

int main() {
   int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
   std::cout << arr[2][1] * arr[0][2];
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 14

The code initializes a 2D array 'arr' with values. The expression 'arr[2][1] * arr[0][2]' multiplies the value at row 2, column 1 (which is 8) with the value at row 0, column 2 (which is 3). The result is 24, and the output will be 24.

Test: 2D Arrays - Question 15

What will be the output of the following code?
#include <iostream>

int main() {
   int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
   std::cout << arr[2][0] / arr[1][1];
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 15

The code initializes a 2D array 'arr' with values. The expression 'arr[2][0] / arr[1][1]' divides the value at row 2, column 0 (which is 7) by the value at row 1, column 1 (which is 5). The result is 1, and the output will be 1.

Test: 2D Arrays - Question 16

Given the following 2D array, what will be the output of the code?

#include <iostream>

int main() {
   int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
   std::cout << *(arr[1] + 2);
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 16

The code initializes a 2D array 'arr' with values. The expression '*(arr[1] + 2)' accesses the element at index 2 in the second row (row index 1). This is equivalent to 'arr[1][2]', which is 6. The output will be 6.

Test: 2D Arrays - Question 17

Given the following 2D array, what will be the output of the code?
#include <iostream>

int main() {
   int arr[3][2] = {{1, 2}, {3, 4}, {5, 6}};
   std::cout << *(*(arr + 2) + 1);
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 17

The code initializes a 2D array 'arr' with values. The expression '*(*(arr + 2) + 1)' accesses the element at row 2 (row index 2) and column 1 (column index 1). This is equivalent to 'arr[2][1]', which is 6. The output will be 6.

Test: 2D Arrays - Question 18

Given the following 2D array, what will be the output of the code?
#include <iostream>

int main() {
   int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
   std::cout << arr[1] - arr[0];
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 18

The code subtracts 'arr[0]' (which is a pointer to the first row) from 'arr[1]' (which is a pointer to the second row). Subtracting two pointers of the same type is not allowed in C++, so it results in a compilation error.

Test: 2D Arrays - Question 19

Given the following 2D array, what will be the output of the code?

#include <iostream>

int main() {
   int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
   std::cout << sizeof(arr) / sizeof(arr[0]);
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 19

The code uses the 'sizeof' operator to calculate the total size of the 2D array 'arr'. The expression 'sizeof(arr)' returns the total size of the array in bytes. By dividing it by the size of each row ('sizeof(arr[0])'), we get the number of rows. In this case, 'sizeof(arr) / sizeof(arr[0]') is equivalent to '6 / 4', which is 2. The output will be 2.

Test: 2D Arrays - Question 20

Given the following 2D array, what will be the output of the code?
#include <iostream>

int main() {
   int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
   std::cout << sizeof(arr[0]) / sizeof(int);
   return 0;
}

Detailed Solution for Test: 2D Arrays - Question 20

The code uses the 'sizeof' operator to calculate the size of 'arr[0]', which represents the first row of the 2D array 'arr'. The expression 'sizeof(arr[0])' returns the size of the first row in bytes. By dividing it by the size of an 'int' (sizeof(int)), we get the number of elements in the row. In this case, 'sizeof(arr[0]) / sizeof(int)' is equivalent to '12 / 4', which is 3. The output will be 3.

70 videos|45 docs|15 tests
Information about Test: 2D Arrays Page
In this test you can find the Exam questions for Test: 2D Arrays solved & explained in the simplest way possible. Besides giving Questions and answers for Test: 2D Arrays, EduRev gives you an ample number of Online tests for practice

Top Courses for EmSAT Achieve

70 videos|45 docs|15 tests
Download as PDF

Top Courses for EmSAT Achieve