GTU PPS Practical - 44
Write a function Exchange to interchange the values of two variables, say x and y. illustrate the use of this function in a calling function.
#include
void swap(int * , int * );
int main() {
int i = 1, j = 2;
printf("\n Values Before Exchange :");
printf("\n i = %d j = %d", i, j);
swap( & i, & j);
printf("\n Values After Exchange :");
printf("\n i = %d j = %d", i, j);
return 0;
}
void swap(int * a, int * b) {
* a = * a + * b;
* b = * a - * b;
* a = * a - * b;
}