Question

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?

double testd; struct frog h: int testi; double .xy: struct frog turtle, apple, tv[3] testi-2; apple-kturtle; apple->x-ktestd;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
Write out the memory map for the following code, providing all values at the end of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT