Write a function that swaps the values of three int variables. It should have th
ID: 3784070 • Letter: W
Question
Write a function that swaps the values of three int variables. It should have the following prototype: void swap3(int *a, int *b, int *c)
For example, calling swap3(&x, &y, &z) should result in z’s having y’s original
value, y’s having x’s original value, and x’s having z’s original value. Use
assertions to protect the function. Write a unit test of swap3 in a main function.
Illustrate various interesting memory configurations during its execution.
How can swap3 be called in order to swap the values of two variables rather
than three, given that three arguments must be passed
in c language
Explanation / Answer
Since, we are using pass y reference rather than pass by value. The values that are going to reflect in the address of the variable is permanent.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.