Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Please Explain at least one of the exercises:

int a = 10;

int b = 20;

int* p1 = &a;

int* p2 = &b;

a++;

p2++;

Using the code above. Suppose the variable a lives at memory address 128, and b lives at the memory address 256. The size of an integer is 4 bytes. After execution of the above code, draw boxes for each of the 4 variables a, b, p1 and p2, label with the name of the variable, and show their integer values. For p1 and p2, draw an additional arrow to where it points. Include the address of the variables 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 memory address 512, and d lives at the memory address 1024. The size of an integer is 4 bytes. After execution of the above code, draw labelled boxes for each of the 4 variables c, d, r1 and r2, and show their integer values. For r1 and r2, draw an additional arrow to where it points. Include addresses of boxes where applicable.

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 after execution of the above code show the contents of each box. Assume w lives at memory address 128, x lives at 256, y lives at 512, and z lives at 1024. In addition, draw arrows from f, g, h and i to where they point. Include addresses of boxes where applicable.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions

Question

What can you do to prevent unethical behavior?

Answered: 1 week ago