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

This is for a C program. Assume that the program is running and that execution h

ID: 3775811 • Letter: T

Question

This is for a C program. Assume that the program is running and that execution has reached the point marked HERE in the function named second. On the worksheet draw the current memory state for all variables and arguments in all three functions (except for the main arguments argc and argv). Variables and arguments that are local to each function should appear in the “function memory” rectangle associated with that function; arrows may/should extend between variables in different functions’ memory rectangles as appropriate. No variables should appear outside of a function memory rectangle.

int main (int argc, chart argv float x 5; float xp & x; doit (*xp); return 0 void doit (float y) float* yp second (yp) float second float* a) float tmp *a, tmp 6 a HERE return tmp; main function memory doit function memory second function memory

Explanation / Answer

main function memory:

float x = 5; //Assume address of x is 0xABCD0000

float *xp = &x; So, xp = 0xABCD0000

doit function memory:

float y = 5; //Assume address of y = 0xBCDE0000 (After update i.e., at point HERE y = 11.)

float *yp = &y; So, yp = 0xBCDE0000

second function memory:

float *a = 0xBCDE0000;

float tmp = *a; //So, tmp = 5.

*a = tmp + 6; //So, value at location 0xBCDE0000 is updated to 11.

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