Question: The following code uses pointers to manipulate the data stored by the two variables in some way. Take the code and analyze it to produce

The following code uses pointers to manipulate the data stored by the two variables in some way.
Take the code and analyze it to produce a memory table that describes the location and final value
of each variable/pointer/etc. in the program.
int val1=50, val2=45;
cout val1"," val2
"
";
int* ptr1= &val2;
int val3=*ptr1;
ptr1= &val1;
int* ptr2= &val2;
*ptr2=*ptr1;
ptr1= &val3;
ptr2= &val1;
*ptr2=*ptr1;
cout val1"," val2
"
";
The following code uses pointers to manipulate

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!