Question: Which of the following is true after executing this code? ( the line numbers are for your reference and have no meaning in the code

Which of the following is true after executing this code? (the line numbers are for your reference and have no meaning in the code)
Line 1: int var1=500;
Line 2: int var2=1000;
Line 3: int * ptr1= &var1;
Line 4:*ptr1=2000;
Line 5: int * ptr2= ptr1;
Line 6: ptr1= &var2;
Which of the following is true after executing this code? (the line numbers are for your reference and have no meaning in the code)
Line 1: int var1=500;
Line 2: int var2=1000;
Line 3: int * ptr1= &var1;
Line 4:*ptr1=2000;
Line 5: int * ptr2= ptr1;
Line 6: ptr1= &var2;
ptr1 contains 2000
Running the following code after Line 6
*ptr2=50;
would put 50 in ptr2
Running the following code after Line 6
*ptr2=50;
would put 50 in var2
Running the following code after Line 6
*ptr2=50;
would put 50 in var1
var1 contains 2000
Running the following code after Line 6
*ptr1=10;
would put 10 in var2
Running the following code after Line 6
*ptr1=10;
would put 10 in var1
Running the following code after Line 6
*ptr2=50;
would put 50 in ptr1

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!