Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use gdb to determined the address of the variables first and last. Show the values in these two addresses after each step (in the C-code)
Use gdb to determined the address of the variables first and last. Show the values in these two addresses after each step (in the C-code) of the two functions (swap and inplace_swap). #include
void swap (int *x, int *y){ int tmp; tmp = *x; /* step 1 */ *x = *y; /* step 2 */ *y = tmp; /* step 3 */ } void inplace_swap(int *x, int *y) { *y = *x ^ *y; /* Step 1 */ *x = *x ^ *y; /* Step 2 */ *y = *x ^ *y; /* Step 3 */ } int main() { long int first = 0x0987654321FEDCBA; long int second = 0xABCDEF1234567890; printf("first %d second %d ", first, second); swap(&first,&second); printf("first %d second %d ", first, second); inplace_swap(&first,&second); printf("first %d second %d ", first, second); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started