1D and 2D Array Addressing MCQs: 12 Solved Questions
Solve 12 array-address questions step by step, from negative lower bounds and 1D offsets to row-major, column-major, triangular and tri-diagonal storage.
KnowledgeGate Team
Exam prep & CS education

Remembering base + offset is not enough when an inclusive bound, element width, or storage order is missed. Array addressing ranges from 1D offsets to compact matrix storage. Attempt each one first, then check your working against the 1D and 2D addressing practice hub.
Inclusive bounds and the 1D address formula
For A[L..U], use U - L + 1 elements and LOC(A[k]) = base + (k - L) × element width. Both endpoints count, and the base belongs to index L.
Question 1: inclusive range
Coal India 2017, Computer Science
The number of elements in a one-dimensional array with lowest and highest index values as -1024 and 1024 is:
A. 2048
B. 0
C. 1024
D. 2049
Answer: D. 1024 - (-1024) + 1 = 1024 + 1024 + 1 = 2049. Option A, 2048, is only the endpoint distance. Check: indices -1, 0, 1 contain 1 - (-1) + 1 = 3 elements, not 2.
Question 2: address in a one-based array
Indian Space Research Organization 2009, Computer Science
A one-dimensional array A has indices 1 through 75. Each element is a string that occupies three memory words. The base address of the array is decimal location 1120. What is the starting address of A[49]?
A. 1267
B. 1164
C. 1264
D. 1169
Answer: C. With lower bound 1, A[49] has 48 preceding elements. Its displacement is (49 - 1) × 3 = 48 × 3 = 144 words, so its address is 1120 + 144 = 1264. Using 49 × 3 produces 1267, option A, as if an element preceded A[1].
See row-major order as a memory sequence
Row-major storage completes each row in sequence. Array Basics MCQs in C combines declarations, output traces, and array algorithms; here, every option turns on a 1D or 2D address calculation.
Question 3: flatten a matrix by rows
Accenture 2023
If row-major order is used, how is the following matrix stored in memory?
a b c
d e f
g h i
A. ihgfedcba
B. abcdefghi
C. cfibehadg
D. adgbehcfi
Answer: B. Rows 0, 1, and 2 are a b c, d e f, and g h i, giving abcdefghi. Option D, adgbehcfi, is column-major; A reverses the elements, and C follows neither order.

Derive row-major formulas for different lower bounds
For A[Lr..Ur][Lc..Uc], calculate N = Uc - Lc + 1, then use LOC(A[i][j]) = B + ((i - Lr) × N + (j - Lc)) × W. Substitute bounds before simplifying.
Question 4: zero-based row-major expression
BEL 2023, Computer Science, Probationary Engineer
Consider 2 dimensional array A[10][15]. Assume that each element takes one memory location and base address of array A is 100. Consider the lower bound of row and column as 0. What is the address of A[i][j] if array A is stored in row major form?
A. i + 15j + 100
B. 10i + j + 100
C. i + 10j + 100
D. 15i + j + 100
Answer: D. Each row contributes 15 elements, so the offset is 15i + j and the address is 100 + 15i + j. The coefficient of i is 15 because advancing it skips all 15 columns; row count 10 does not control the jump.
Question 5: one-based row-major expression
GATE 1998, Computer Science
Let A be a two dimensional array declared as follows: A: array [1 … 10] [1 … 15] of integer; Assuming that each integer takes one memory location, the array is stored in row-major order and the first element of the array is stored at location 100, what is the address of the element a[i][j]?
A. 15i + j + 84
B. 15j + i + 84
C. 10i + j + 89
D. 10j + i + 89
Answer: A. Insert the one-based bounds: 100 + (i - 1) × 15 + (j - 1). This expands to 100 + 15i - 15 + j - 1 = 15i + j + 84. For A[1][1], 15 + 1 + 84 = 100, the stated base.
Calculate row-major addresses with element width
Find the linear offset, then multiply by element width. The lower-bound indices must return the base, and one column right must add one element width.
Question 6: unusual column lower bound
UP Police 2013, Computer Science, Paper 2 - Subject Oriented (Shift I)
Consider a two dimensional character array A [1:5, 2:7]. Assuming row major order of storage determine the address of element A[2][3] if base address is 500.
A. 501
B. 506
C. 507
D. 508
Answer: C. The column extent is 7 - 2 + 1 = 6, and the offset is (2 - 1) × 6 + (3 - 2) = 6 + 1 = 7. A character occupies one location, so the address is 500 + 7 = 507. The trap is forgetting to subtract lower bound 2 from 3.
Question 7: multiply before adding the base
Cognizant 2025
Consider a two dimensional array A[20][10]. Assume 4 words per memory cell, the base address of array A is 100, elements are stored in row-major order and first element is A[0][0]. What is the address of A[11][5] ?
A. 560
B. 460
C. 570
D. 575
Answer: A. Ten columns give offset 11 × 10 + 5 = 115. In words, 115 × 4 = 460; adding the base gives 100 + 460 = 560. Option B is the displacement without the base.
Switch to column-major order and pointer expressions
Column-major order completes each column in sequence: LOC(A[i][j]) = B + ((j - Lc) × number of rows + (i - Lr)) × W. For pointer notation, distinguish an element from a row.
Question 8: column-major with negative bounds
Consider a two-dimensional array A of integers declared as int A[-5..5][1..10]. The first element is stored at the location 1500. Assume that each integer takes 4 memory locations. What is the address of element A[4][5] if the array is stored in column major order?
A. 1774
B. 1668
C. 1712
D. 1096
Answer: C. The row count is 5 - (-5) + 1 = 11. The offset is (5 - 1) × 11 + (4 - (-5)) = 44 + 9 = 53, so 1500 + 53 × 4 = 1500 + 212 = 1712. Column displacement uses the row count.
Question 9: array syntax and pointer arithmetic
Coal India 2017, Computer Science
If P is a two-dimensional array having 10 rows and 20 columns, then which of the following cannot be used to access the element in row 2 and column 5?
A. P[2][5]
B. * (* (P + 2) + 5)
C. *(P[2] + 5)
D. *(P + 2 + 5)
Answer: D. P[2][5] = *(*(P + 2) + 5) and P[2] = *(P + 2), so C is equivalent. In D, P + 2 + 5 becomes P + 7; P advances by rows, reaching row 7 rather than column 5 of row 2. See Pointers in C for GATE for this scaling rule.
Count bounded arrays and compress triangular storage
Multiply the two inclusive extents. In compact storage, count only retained entries before the requested position.
Question 10: total elements in a bounded array
DSSSB 2021, Computer Science, TGT - Shift 5
What is the total number of elements in an array E[-4 : 1, 6 : 10]?
A. 30
B. 20
C. 9
D. 11
Answer: A. The extents are 1 - (-4) + 1 = 6 and 10 - 6 + 1 = 5. A 2D array uses their product, 6 × 5 = 30. Adding them gives 11, option D, but misses the row-column combinations.
Question 11: lower-triangular compact index
GATE 1994, Computer Science
In a compact one dimensional array representation for lower triangular matrix (all elements above diagonal are zero) of size n × n, non zero elements of each row are stored one after another, i.e. elements of lower triangle of each row are stored one after another, starting from first row, the index of (i, j)th element of the lower triangular matrix in this new representation is
A. i + j
B. i + j - 1
C. j - 1 + i(i - 1)/2
D. i + j(j - 1)/2
Answer: C. With one-based matrix coordinates and a zero-based compact index, rows before row i contribute 1 + 2 + ... + (i - 1) = i(i - 1)/2 entries. Column j has offset j - 1, giving j - 1 + i(i - 1)/2. For i = 4, j = 2, it is 1 + 4 × 3 / 2 = 1 + 6 = 7.
Tri-diagonal compact indexing
A tri-diagonal matrix keeps only the diagonal and its two neighbouring bands, so the first and last rows hold two entries each and every interior row holds three. Count those stored entries before the requested position.
Question 12: derive the compact position
DSSSB 2021, Computer Science, PGT
Consider an n × n tri-diagonal sparse matrix A. Suppose we want to store the non-zero elements of A in a one-dimensional array using row-major order. Assuming 1-based row and column indices i, j, and a 1-based index for the one-dimensional array, what is the index of the (i, j)th element of A in the one-dimensional array?
A. 2i + 2j
B. 2i + j - 2
C. i + j
D. i + j - 1
Answer: B. Before row i, row 1 contributes 2 entries and rows 2 through i - 1 contribute 3 each. The position in row i yields 2i + j - 2. For i = 4, j = 3, earlier rows hold 2 + 3 + 3 = 8 entries, so the target is 9; 2(4) + 3 - 2 = 9. At the boundary, (1,1) gives 1 and (1,2) gives 2. The formula applies only inside the tri-diagonal band.
The short version
Check lower bounds, the contiguous dimension, the element offset, and width before adding the base. Reattempt Questions 5, 8, 11, and 12 for one-based bounds, column-major order, triangular indexing, and tri-diagonal indexing.
For the complete sequence, continue with GATE Guidance by Sanchit Sir. If you are mapping this topic into wider exam preparation, use the GATE CS exam preparation courses and test series page to choose the relevant path.
Keep learning

3D and Multidimensional Array MCQs: 10 Solved Questions with Explanations
Solve ten multidimensional-array questions with lower-bound normalisation, address formulas, array transformations, and careful step-by-step traces.

Structure Modification and Pointer Logic MCQs: 10 Solved Linked List Questions
Solve 10 linked-list MCQs by tracing each pointer update. The explanations cover reversal, duplicate removal, deletion, insertion, sentinels, and invalid links.

Binary Tree Properties MCQs: 12 Solved Questions with Explanations
Work through 12 binary tree MCQs from GATE and campus papers, then use the explanations and one worked tree to fix mistakes in shape, degree and recursion.

Stack Basics and Operations MCQs: 12 Solved Questions with Step-by-Step Explanations
Test stack fundamentals through 12 exam MCQs on LIFO, TOP, array bounds, queue transfers and permutations. Complete traces make every state and answer checkable.