Question

Question 2 [12pts 3pts each]: Trace the execution of the following fragment and write the final values of the variables w, x, *wp and *xp in the boxes provided below: *wp: x: *xp: w: int w- 12, x = 5; int *wp = NULL, *xp NULL ; int tmp = *xp ; x = *wp ; w tmp ;
0 0
Add a comment Improve this question Transcribed image text
Answer #1

int w = 12;
int x = 5;
int *wp = NULL;
int *xp = NULL;
wp = &w; //address of w
xp = &x; // address of x
int tmp = *xp; // value at xp = value of x
x = *wp; // value at wp = value of w
w = tmp;​ // value at tmp = value of x

The values of x and w are swapped but the addresses are same

w = 5

x = 12

*wp = 0x7ffea31f3d18

*xp = 0x7ffea31f3d1c

Add a comment
Know the answer?
Add Answer to:
Question 2 [12pts 3pts each]: Trace the execution of the following fragment and write the final...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT