COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
4050
|
|
4040
|
|
5050
|
|
5040
|
Detailed explanation-1: -Consider the following declaration of a two-dimensional array in C: char a [ 100 ] [ 100 ]; Assuming that the main memory is byte-addressable and that the array is stored starting from memory address, the address of a [ 40 ] [ 50 ] is: 4040.
Detailed explanation-2: -A 2D array is stored in the computer’s memory one row following another. The address of the first byte of memory is considered as the memory location of the entire 2D array.
Detailed explanation-3: -Like the one-dimensional arrays, two-dimensional arrays may be initialized by following their declaration with a list of initial values enclosed in braces. Ex: int a[2][3]=0, 0, 0, 1, 1, 1; initializes the elements of the first row to zero and the second row to one. The initialization is done row by row.
Detailed explanation-4: -To declare a two-dimensional array using both dimensions, we just have to pass the number of rows and the number of columns of the matrix in the square brackets as shown below: int[][] a = new int[2][2];