English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

In two dimensional array X(7,9) each element occupies 2 bytes of memory.If the address of first element X(1,1)is 1258 then what will be the address of the element X(5,8) ?

2006-09-14 23:00:41 · 2 answers · asked by Anonymous in Science & Mathematics Mathematics

2 answers

Your array have 7 rows and 9 cols
so the element(5,8) is in the fifth row and 8th col
in computer, 2D arrays implement as a linear array
so to access X(5,8) you must pass 4 rows (each containing 9 elements) and seven cols
so the answer is
1285+4*9*2+7*2
more explane:
1258+4(4 rows)*9(9 element in each row)*2(size of each element)+7(7 elements in 5th row)*2(size of each element)

2006-09-16 11:27:33 · answer #1 · answered by Nexus 2 · 0 0

depends on the compiler usually a 2dim array occupies the address base until base + dimension of the array

so in your case the element X(5,8) is at adress : 1258 + 2*5*8

2006-09-15 06:25:27 · answer #2 · answered by gjmb1960 7 · 0 0

fedest.com, questions and answers