ECE 263/ECE264 Name Quiz 4/ Quiz2 Show work Due March 28 1. Suppose that we have
ID: 3736940 • Letter: E
Question
ECE 263/ECE264 Name Quiz 4/ Quiz2 Show work Due March 28 1. Suppose that we have made the declarations short CR[18]; short *p, *w, *z,*f; long TR[151 11,21,31,41,51,61,71,81); long MICR+1, CR+10, CR+2) double K[10][7]; double *sptrl; * we now make the following assignments*/ P-&CR12;]; z-w-4; sptri-K3]; For the purpose of this exercise assume the address for CR is 3400, address for TR is 4500, address for M is 9000 and the address for K is 7500. Here addresses are given in base 10. Answer the following (a) Determine w (b) determine w-p; (c) pt-4 Determine p (d) w+-2 (e) Determine MI2] (f) Determine *M[2] determine w (g) determine sptri (h) sptr1++; determine sptriExplanation / Answer
Solution:
Initially:
CR = 3400
TR = 4500
M = 9000
K = 7500
(a)
Now w = CR+8. According to the initialization.
CR holds the base address of the short array CR, which is equal to 3400.
Now since CR is short integer, every iteration on it is of size 2 bytes.
So, w = CR + 8 = 3400 + 2x8 = 3416.
Therefore w = 3416
(b)
Now, p is initialised as: p = &CR[2], Hence it points to the 3rd location in the CR array.
Whereas, w points to the 9th location in the CR array (Since the array index starts at 0).
So, w-p = 6.
(c)
Now, p = &CR[2], i.e, CR + 3x2 = 3406
then, p = p+4 = 3406 + 4x2 = 3414.
Therefore p = 3414
(d)
Simillarly, w = 3416.
Now, w= w +2 = 3416 + 2x2 = 3420
Therefore w = 3420
(e)
M[2] denotes the 3rd element of the M array, which is CR + 2.
So, M[2] = 3400 + 2x2 = 3404
(f)
*M[2] points to CR + 2, And its seen that there is no Value at CR + 2 address, i.e. the 3rd element of CR is empty. Hence, Value of M[2] is 0 or null.
(g)
sptr1 = K[3]. This means that it denotes the base address of the 3rd index.
Since the data type of K is double, each element is of size 8 bytes.
so, sptr1 = K + 3x7x8 = 7500 + 168 = 7668.
(h)
sptr1++ = sptr1+1 = 7668 + 1x8 = 7676.
Since, the size is double, hence it takes 8 bytes.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.