Write out the memory map for the following code, providing all
values at the end of execution.
How many total bytes does this code declare for variables?
IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU
ANSWER:
EXPLANATION:
AS PER THE QUESTION GIVEN
double testd; // 8 bytes
int testi; // 4 bytes
struct frog
{
double *x,y; // 4+8 = 12 bytes
}
struct frog turtle,*apple,tv[3]; // 12 bytes , 4 bytes , 12*3 = 36 bytes
testi = 2;
apple = &turtle;
apple->x = &testd;
*(turtle.x) = 7.3;
(*apple).y = 3.6;
turtle.y = 1.5;
for(testi=0;testi<3;testi++)
tv[testi].x = &(tv[(testi+i)%3].y);
*(tv[1].x) = 6.4;
Memory Map
testd (address 3400)
7.3 |
testi (address 6800)
turtle (address = 2002)
&testd = 3400 | 1.5 |
apple
2002 |
tv[3]
tv[0]:x = 3988 | y | tv[1] : x = 4000 | 2y | tv[2]:4012 | 0 |
x
4000 |
Total bytes used for variables =
double testd; // 8 bytes
int testi; // 4 bytes
struct frog turtle,*apple,tv[3]; // 12 bytes , 4 bytes , 12*3 = 36 bytes
= 8+4+12+4+36 = 64 bytes
HOPE IT HELPS YOU
RATE THUMBSUP PLEASE
Write out the memory map for the following code, providing all values at the end of...