ITPEC FE Morning April 2018 Question 6
ITPEC FE Morning April 2018 — Question 6 of 80
Two-Dimensional Array Element Calculation — evaluating nested array index expressions using a formula-defined 2D array.
Given: A[i, j] = 2 × i + j
Step 1 — Compute inner index values:
- A[1, 1] = 2 × 1 + 1 = 3
- A[2, 2] = 2 × 2 + 2 = 6
Step 2 — Compute outer indices:
- First index: A[1, 1] × 2 = 3 × 2 = 6
- Second index: A[2, 2] + 1 = 6 + 1 = 7
Step 3 — Final evaluation:
- A[6, 7] = 2 × 6 + 7 = 19
Why not others:
- (a) 12 — would result from miscalculating one of the intermediate values
- (b) 13 — arithmetic error in index computation
- (c) 18 — would occur if the formula were misread as 2 × (i + j)
Key rule: Work inside-out — first evaluate the innermost array references, then use those results as indices for the outer reference.
AI-generated — may contain errors
The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.