Menu

Please Explain Least One Exercises Int 10 Int B 20 Int P1 Int P2 B P2 Using Code Suppose Q43884876

Please Explain at least one of theexercises:

int a = 10;

int b = 20;

int* p1 = &a;

int* p2 = &b;

a++;

p2++;

Using the code above. Suppose the variable a lives at memoryaddress 128, and b lives at the memory address 256. The size of aninteger is 4 bytes. After execution of the above code, draw boxesfor each of the 4 variables a, b, p1 and p2, label with the name ofthe variable, and show their integer values. For p1 and p2, draw anadditional arrow to where it points. Include the address of thevariables next to the variables where those values are known.

Now consider this code using references:

int c = 75;

int d = 100;

int& r1 = c;

int& r2 = d;

c++;

r2++;

Use the code above. Suppose the variable c lives at memoryaddress 512, and d lives at the memory address 1024. The size of aninteger is 4 bytes. After execution of the above code, drawlabelled boxes for each of the 4 variables c, d, r1 and r2, andshow their integer values. For r1 and r2, draw an additional arrowto where it points. Include addresses of boxes whereapplicable.

int w = 1;

int x = 2;

int* f = &w;

int* g = &x;

int y = 3;

int z = 4;

int& h = y;

int& i = z;

f = g;

h = i;

Draw labelled boxes for each of the 8 variables, and afterexecution of the above code show the contents of each box. Assume wlives at memory address 128, x lives at 256, y lives at 512, and zlives at 1024. In addition, draw arrows from f, g, h and i to wherethey point. Include addresses of boxes where applicable.

Expert Answer


Answer to Please Explain at least one of the exercises: int a = 10; int b = 20; int* p1 = &a; int* p2 = &b; a++; p2++; Using the c…

OR