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

#4 (10point The code on the left side is executed sequentially. The boxes on the

ID: 3904632 • Letter: #

Question

#4 (10point The code on the left side is executed sequentially. The boxes on the right show the variables and the adresses (in decimal) where they are located in memory. After the code for each part is fully executed, fill in each variable's box with its current value. Also, draw an arrow from each pointer variable to whichever variabie currently referencing. Assume 4 byte integers Update these boxes after the part's code has been fully executed Address Address /I Part (a) int x 125; int y int *p &y; int *w; - 1000 3000 Address Address 1004 /I Part (b) p 67; w 42 1000 Address Address 1004 :Address 3000 /1 Part (c) 1000 "(p+1) 100; = Address Address l y 4000 1004 // Part (d) w = NULL; "p 999 Address Address 3000 1000 AddressW Address 4000 1004

Explanation / Answer

Part a
p = 1004 x = 125 w = 3000 y = Unknown    (p is pointing to y)
                                          (w is poinying to p)
Part b
p = 1004 x = 125 w = 3000 y = 42       

Part c
p = 1000 x = 125 w = 3000 y = 100        p is pointing to x
                                          w is pointing to p

Part d
p = 1000 x = 999 w = 0 y = 100        p is pointing to x
                                          w is pointing to p