This is for a C program Assume that the program is running a
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 memorySolution
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.
