Write a function that swaps the values of three int variable

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

Solution

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.

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 s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site