Isaac H.

asked • 04/04/23

Consider the following code fragment.

Consider the following code fragment.

(a) Draw the pictorial representation of the memory, starting from the first line of code and ending with the last line of code (all in one picture so I can see the changes).

(b) This code has a problem. What is it? What is it called?

double x = 1.5, y = 3.4;
double* p = &x;
double* p2 = new double[12];

*p += y;
p = &y;
*p *= 2;

for (int i{ 0 }; i < 12; ++i)
{
p2[i] = 1.6;
}

p2 = p;
delete p2;

1 Expert Answer

By:

Jerry C. answered • 04/04/23

Tutor
New to Wyzant

Gain Confidence with Math

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.