#include /* We declare function that exchanges values of its arguments. It does not return any value since this function is useful because of its side-effects achieved by using pointers. */ void swap(int *n, int *m); int main( void ) { int i, j; printf("Enter two positive integers: "); scanf("%d %d", &i, &j); printf("Before swapping i= %d j= %d\n", i, j); swap(&i, &j); /* exchange values of the arguments */ printf("After swapping i= %d j= %d\n", i, j); return( 0 ); } /* This function takes address of the 1st number in its 1st argument, address of the 2nd number in its second argument. It stores temporary the value of the 1st argument in a variable temp. Then, it assigns the value of the 2nd argument to the address pointed by the 1st argument. After that, it assigns to the address pointed by the 2nd argument the value stored in temp. Exchange of the values has been completed. */ void swap(int *n, int *m) { int temp; temp = *n; *n = *m; *m = temp; /*there is no value to return because we have already exchanged the arguments*/ }