Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is from a textbook on C++ Find where the indicated elements of a two dimens

ID: 3620457 • Letter: T

Question

This is from a textbook on C++
Find where the indicated elements of a two dimensional array t of the specified type are stored, if the base address of t is 100 and storage rowwise.

double t[4][10]; double t[0][8] and double t[3][2]

This question is the following:

double t[4][10];
the array name is t
The array dimensions are 4-rows and 10-cols
base address of the array is 100

Now, the question is the following: what are the addresses of the following elements, if the base address of the array is at 100:

element t[0][8]
element t[3][2]
-------------------------------------------
Here's an example of one that's done already:
int t[8][7];
int t[3][2] = 152
int t[1][6] = 192

Explanation / Answer

please rate -thanks element t[0][0] is at location 100 since it is rowwise the matrix is stored as 10 elements row 0 are stored then 10 element row 1 then 10 elements row 2 etc you are interested in element [0][8] it is the 9th element stored in the array. each element is 4 bytes so
element t[0][8]=136 t[3][2] there are 3 complete rows + 2 elements stored before this element.
each row has 10 elements, so there are 10*3 + 2 =32 elements before this element. each element is 4 bytes. 32*4=128. element t[3][2]=228
this example is incorrect.
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote